diff --git a/sandbox/.gitignore b/sandbox/.gitignore index 610051b88..bf03f040f 100644 --- a/sandbox/.gitignore +++ b/sandbox/.gitignore @@ -3,33 +3,43 @@ dotnet/* !dotnet/hellosign_sandbox.csproj !dotnet/NuGet.Config !dotnet/Program.cs +!dotnet/src/Dropbox.SignSandbox.Test +!dotnet/test_fixtures java-v1/* !java-v1/pom.xml !java-v1/src java-v1/src/main/java/com/dropbox/sign_sandbox/* !java-v1/src/main/java/com/dropbox/sign_sandbox/Main.java +!java-v1/test_fixtures java-v2/* !java-v2/pom.xml !java-v2/src java-v2/src/main/java/com/dropbox/sign_sandbox/* !java-v2/src/main/java/com/dropbox/sign_sandbox/Main.java +!java-v2/test_fixtures node/* !node/Example.ts !node/package.json +!node/tests +!node/test_fixtures php/* -!php/Example.php !php/composer.json +!php/Example.php +!php/test +!php/test_fixtures python/* !python/Example.py !python/requirements.txt +!python/tests +!python/test_fixtures ruby/* !ruby/Example.rb !ruby/Gemfile - -!**/pdf-sample.pdf +!ruby/spec +!ruby/test_fixtures diff --git a/sandbox/dotnet/test_fixtures/SignatureRequestCreateEmbeddedRequest.json b/sandbox/dotnet/test_fixtures/SignatureRequestCreateEmbeddedRequest.json new file mode 100644 index 000000000..f9bd157f8 --- /dev/null +++ b/sandbox/dotnet/test_fixtures/SignatureRequestCreateEmbeddedRequest.json @@ -0,0 +1,163 @@ +{ + "allow_decline": true, + "allow_reassign": true, + "attachments": [ + { + "name": "Attachment1", + "signer_index": 1, + "instructions": "Upload your Driver's License", + "required": true + } + ], + "cc_email_addresses": [ + "lawyer1@example.com", + "lawyer2@example.com" + ], + "field_options": { + "date_format": "MM / DD / YYYY" + }, + "form_field_groups": [ + { + "group_id": "radio_group_1", + "group_label": "Radio Group 1", + "requirement": "require_0-1" + } + ], + "form_field_rules": [ + { + "id": "rule_1", + "trigger_operator": "AND", + "triggers": [ + { + "id": "api_id_1", + "operator": "is", + "value": "foo" + } + ], + "actions": [ + { + "field_id": "api_id_2", + "hidden": true, + "type": "change-field-visibility" + } + ] + } + ], + "form_fields_per_document": [ + { + "document_index": 0, + "api_id": "api_id_1", + "name": "field_1", + "type": "text", + "x": 0, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": "0", + "page": 1, + "font_family": "roboto", + "font_size": 11 + }, + { + "document_index": 0, + "api_id": "api_id_2", + "name": "field_2", + "type": "text", + "x": 300, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": 0, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_3", + "name": "field_3", + "type": "dropdown", + "options": [ + "Option 1", + "Option 2", + "Option 3" + ], + "x": 0, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": 1, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_4", + "name": "field_4", + "type": "text", + "x": 300, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": "1", + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_5", + "name": "field_5", + "type": "radio", + "group": "radio_group_1", + "is_checked": true, + "x": 0, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + }, + { + "document_index": 0, + "api_id": "api_id_6", + "name": "field_6", + "type": "radio", + "group": "radio_group_1", + "is_checked": false, + "x": 300, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + } + ], + "message": "Please sign this NDA and then we can discuss more. Let me know if you have any questions.", + "metadata": { + "custom_id": 1234, + "custom_text": "NDA #9" + }, + "signers": [ + { + "email_address": "s1@example.com", + "name": "Signer 1", + "order": 0 + }, + { + "email_address": "s2@example.com", + "name": "Signer 2", + "order": 1 + }, + { + "email_address": "s3@example.com", + "name": "Signer 3", + "order": 2 + } + ], + "test_mode": true +} diff --git a/sandbox/dotnet/test_fixtures/SignatureRequestSendRequest.json b/sandbox/dotnet/test_fixtures/SignatureRequestSendRequest.json new file mode 100644 index 000000000..9560ddd52 --- /dev/null +++ b/sandbox/dotnet/test_fixtures/SignatureRequestSendRequest.json @@ -0,0 +1,163 @@ +{ + "allow_decline": true, + "allow_reassign": true, + "attachments": [ + { + "name": "Attachment1", + "signer_index": 1, + "instructions": "Upload your Driver's License", + "required": true + } + ], + "cc_email_addresses": [ + "lawyer1@example.com", + "lawyer2@example.com" + ], + "field_options": { + "date_format": "DD - MM - YYYY" + }, + "form_field_groups": [ + { + "group_id": "radio_group_1", + "group_label": "Radio Group 1", + "requirement": "require_0-1" + } + ], + "form_field_rules": [ + { + "id": "rule_1", + "trigger_operator": "AND", + "triggers": [ + { + "id": "api_id_1", + "operator": "is", + "value": "foo" + } + ], + "actions": [ + { + "field_id": "api_id_2", + "hidden": true, + "type": "change-field-visibility" + } + ] + } + ], + "form_fields_per_document": [ + { + "document_index": 0, + "api_id": "api_id_1", + "name": "field_1", + "type": "text", + "x": 0, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": "0", + "page": 1, + "font_family": "roboto", + "font_size": 11 + }, + { + "document_index": 0, + "api_id": "api_id_2", + "name": "field_2", + "type": "text", + "x": 300, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": 0, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_3", + "name": "field_3", + "type": "dropdown", + "options": [ + "Option 1", + "Option 2", + "Option 3" + ], + "x": 0, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": 1, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_4", + "name": "field_4", + "type": "text", + "x": 300, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": "1", + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_5", + "name": "field_5", + "type": "radio", + "group": "radio_group_1", + "is_checked": true, + "x": 0, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + }, + { + "document_index": 0, + "api_id": "api_id_6", + "name": "field_6", + "type": "radio", + "group": "radio_group_1", + "is_checked": false, + "x": 300, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + } + ], + "message": "Please sign this NDA and then we can discuss more. Let me know if you\nhave any questions.", + "metadata": { + "custom_id": 1234, + "custom_text": "NDA #9" + }, + "signers": [ + { + "email_address": "s1@example.com", + "name": "Signer 1", + "order": 0 + }, + { + "email_address": "s2@example.com", + "name": "Signer 2", + "order": 1 + }, + { + "email_address": "s3@example.com", + "name": "Signer 3", + "order": 2 + } + ], + "test_mode": true +} diff --git a/sandbox/dotnet/pdf-sample.pdf b/sandbox/dotnet/test_fixtures/pdf-sample.pdf similarity index 100% rename from sandbox/dotnet/pdf-sample.pdf rename to sandbox/dotnet/test_fixtures/pdf-sample.pdf diff --git a/sandbox/java-v1/test_fixtures/SignatureRequestCreateEmbeddedRequest.json b/sandbox/java-v1/test_fixtures/SignatureRequestCreateEmbeddedRequest.json new file mode 100644 index 000000000..f9bd157f8 --- /dev/null +++ b/sandbox/java-v1/test_fixtures/SignatureRequestCreateEmbeddedRequest.json @@ -0,0 +1,163 @@ +{ + "allow_decline": true, + "allow_reassign": true, + "attachments": [ + { + "name": "Attachment1", + "signer_index": 1, + "instructions": "Upload your Driver's License", + "required": true + } + ], + "cc_email_addresses": [ + "lawyer1@example.com", + "lawyer2@example.com" + ], + "field_options": { + "date_format": "MM / DD / YYYY" + }, + "form_field_groups": [ + { + "group_id": "radio_group_1", + "group_label": "Radio Group 1", + "requirement": "require_0-1" + } + ], + "form_field_rules": [ + { + "id": "rule_1", + "trigger_operator": "AND", + "triggers": [ + { + "id": "api_id_1", + "operator": "is", + "value": "foo" + } + ], + "actions": [ + { + "field_id": "api_id_2", + "hidden": true, + "type": "change-field-visibility" + } + ] + } + ], + "form_fields_per_document": [ + { + "document_index": 0, + "api_id": "api_id_1", + "name": "field_1", + "type": "text", + "x": 0, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": "0", + "page": 1, + "font_family": "roboto", + "font_size": 11 + }, + { + "document_index": 0, + "api_id": "api_id_2", + "name": "field_2", + "type": "text", + "x": 300, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": 0, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_3", + "name": "field_3", + "type": "dropdown", + "options": [ + "Option 1", + "Option 2", + "Option 3" + ], + "x": 0, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": 1, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_4", + "name": "field_4", + "type": "text", + "x": 300, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": "1", + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_5", + "name": "field_5", + "type": "radio", + "group": "radio_group_1", + "is_checked": true, + "x": 0, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + }, + { + "document_index": 0, + "api_id": "api_id_6", + "name": "field_6", + "type": "radio", + "group": "radio_group_1", + "is_checked": false, + "x": 300, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + } + ], + "message": "Please sign this NDA and then we can discuss more. Let me know if you have any questions.", + "metadata": { + "custom_id": 1234, + "custom_text": "NDA #9" + }, + "signers": [ + { + "email_address": "s1@example.com", + "name": "Signer 1", + "order": 0 + }, + { + "email_address": "s2@example.com", + "name": "Signer 2", + "order": 1 + }, + { + "email_address": "s3@example.com", + "name": "Signer 3", + "order": 2 + } + ], + "test_mode": true +} diff --git a/sandbox/java-v1/test_fixtures/SignatureRequestSendRequest.json b/sandbox/java-v1/test_fixtures/SignatureRequestSendRequest.json new file mode 100644 index 000000000..9560ddd52 --- /dev/null +++ b/sandbox/java-v1/test_fixtures/SignatureRequestSendRequest.json @@ -0,0 +1,163 @@ +{ + "allow_decline": true, + "allow_reassign": true, + "attachments": [ + { + "name": "Attachment1", + "signer_index": 1, + "instructions": "Upload your Driver's License", + "required": true + } + ], + "cc_email_addresses": [ + "lawyer1@example.com", + "lawyer2@example.com" + ], + "field_options": { + "date_format": "DD - MM - YYYY" + }, + "form_field_groups": [ + { + "group_id": "radio_group_1", + "group_label": "Radio Group 1", + "requirement": "require_0-1" + } + ], + "form_field_rules": [ + { + "id": "rule_1", + "trigger_operator": "AND", + "triggers": [ + { + "id": "api_id_1", + "operator": "is", + "value": "foo" + } + ], + "actions": [ + { + "field_id": "api_id_2", + "hidden": true, + "type": "change-field-visibility" + } + ] + } + ], + "form_fields_per_document": [ + { + "document_index": 0, + "api_id": "api_id_1", + "name": "field_1", + "type": "text", + "x": 0, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": "0", + "page": 1, + "font_family": "roboto", + "font_size": 11 + }, + { + "document_index": 0, + "api_id": "api_id_2", + "name": "field_2", + "type": "text", + "x": 300, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": 0, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_3", + "name": "field_3", + "type": "dropdown", + "options": [ + "Option 1", + "Option 2", + "Option 3" + ], + "x": 0, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": 1, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_4", + "name": "field_4", + "type": "text", + "x": 300, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": "1", + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_5", + "name": "field_5", + "type": "radio", + "group": "radio_group_1", + "is_checked": true, + "x": 0, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + }, + { + "document_index": 0, + "api_id": "api_id_6", + "name": "field_6", + "type": "radio", + "group": "radio_group_1", + "is_checked": false, + "x": 300, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + } + ], + "message": "Please sign this NDA and then we can discuss more. Let me know if you\nhave any questions.", + "metadata": { + "custom_id": 1234, + "custom_text": "NDA #9" + }, + "signers": [ + { + "email_address": "s1@example.com", + "name": "Signer 1", + "order": 0 + }, + { + "email_address": "s2@example.com", + "name": "Signer 2", + "order": 1 + }, + { + "email_address": "s3@example.com", + "name": "Signer 3", + "order": 2 + } + ], + "test_mode": true +} diff --git a/sandbox/java-v1/pdf-sample.pdf b/sandbox/java-v1/test_fixtures/pdf-sample.pdf similarity index 100% rename from sandbox/java-v1/pdf-sample.pdf rename to sandbox/java-v1/test_fixtures/pdf-sample.pdf diff --git a/sandbox/java-v2/test_fixtures/SignatureRequestCreateEmbeddedRequest.json b/sandbox/java-v2/test_fixtures/SignatureRequestCreateEmbeddedRequest.json new file mode 100644 index 000000000..f9bd157f8 --- /dev/null +++ b/sandbox/java-v2/test_fixtures/SignatureRequestCreateEmbeddedRequest.json @@ -0,0 +1,163 @@ +{ + "allow_decline": true, + "allow_reassign": true, + "attachments": [ + { + "name": "Attachment1", + "signer_index": 1, + "instructions": "Upload your Driver's License", + "required": true + } + ], + "cc_email_addresses": [ + "lawyer1@example.com", + "lawyer2@example.com" + ], + "field_options": { + "date_format": "MM / DD / YYYY" + }, + "form_field_groups": [ + { + "group_id": "radio_group_1", + "group_label": "Radio Group 1", + "requirement": "require_0-1" + } + ], + "form_field_rules": [ + { + "id": "rule_1", + "trigger_operator": "AND", + "triggers": [ + { + "id": "api_id_1", + "operator": "is", + "value": "foo" + } + ], + "actions": [ + { + "field_id": "api_id_2", + "hidden": true, + "type": "change-field-visibility" + } + ] + } + ], + "form_fields_per_document": [ + { + "document_index": 0, + "api_id": "api_id_1", + "name": "field_1", + "type": "text", + "x": 0, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": "0", + "page": 1, + "font_family": "roboto", + "font_size": 11 + }, + { + "document_index": 0, + "api_id": "api_id_2", + "name": "field_2", + "type": "text", + "x": 300, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": 0, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_3", + "name": "field_3", + "type": "dropdown", + "options": [ + "Option 1", + "Option 2", + "Option 3" + ], + "x": 0, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": 1, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_4", + "name": "field_4", + "type": "text", + "x": 300, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": "1", + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_5", + "name": "field_5", + "type": "radio", + "group": "radio_group_1", + "is_checked": true, + "x": 0, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + }, + { + "document_index": 0, + "api_id": "api_id_6", + "name": "field_6", + "type": "radio", + "group": "radio_group_1", + "is_checked": false, + "x": 300, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + } + ], + "message": "Please sign this NDA and then we can discuss more. Let me know if you have any questions.", + "metadata": { + "custom_id": 1234, + "custom_text": "NDA #9" + }, + "signers": [ + { + "email_address": "s1@example.com", + "name": "Signer 1", + "order": 0 + }, + { + "email_address": "s2@example.com", + "name": "Signer 2", + "order": 1 + }, + { + "email_address": "s3@example.com", + "name": "Signer 3", + "order": 2 + } + ], + "test_mode": true +} diff --git a/sandbox/java-v2/test_fixtures/SignatureRequestSendRequest.json b/sandbox/java-v2/test_fixtures/SignatureRequestSendRequest.json new file mode 100644 index 000000000..9560ddd52 --- /dev/null +++ b/sandbox/java-v2/test_fixtures/SignatureRequestSendRequest.json @@ -0,0 +1,163 @@ +{ + "allow_decline": true, + "allow_reassign": true, + "attachments": [ + { + "name": "Attachment1", + "signer_index": 1, + "instructions": "Upload your Driver's License", + "required": true + } + ], + "cc_email_addresses": [ + "lawyer1@example.com", + "lawyer2@example.com" + ], + "field_options": { + "date_format": "DD - MM - YYYY" + }, + "form_field_groups": [ + { + "group_id": "radio_group_1", + "group_label": "Radio Group 1", + "requirement": "require_0-1" + } + ], + "form_field_rules": [ + { + "id": "rule_1", + "trigger_operator": "AND", + "triggers": [ + { + "id": "api_id_1", + "operator": "is", + "value": "foo" + } + ], + "actions": [ + { + "field_id": "api_id_2", + "hidden": true, + "type": "change-field-visibility" + } + ] + } + ], + "form_fields_per_document": [ + { + "document_index": 0, + "api_id": "api_id_1", + "name": "field_1", + "type": "text", + "x": 0, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": "0", + "page": 1, + "font_family": "roboto", + "font_size": 11 + }, + { + "document_index": 0, + "api_id": "api_id_2", + "name": "field_2", + "type": "text", + "x": 300, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": 0, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_3", + "name": "field_3", + "type": "dropdown", + "options": [ + "Option 1", + "Option 2", + "Option 3" + ], + "x": 0, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": 1, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_4", + "name": "field_4", + "type": "text", + "x": 300, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": "1", + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_5", + "name": "field_5", + "type": "radio", + "group": "radio_group_1", + "is_checked": true, + "x": 0, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + }, + { + "document_index": 0, + "api_id": "api_id_6", + "name": "field_6", + "type": "radio", + "group": "radio_group_1", + "is_checked": false, + "x": 300, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + } + ], + "message": "Please sign this NDA and then we can discuss more. Let me know if you\nhave any questions.", + "metadata": { + "custom_id": 1234, + "custom_text": "NDA #9" + }, + "signers": [ + { + "email_address": "s1@example.com", + "name": "Signer 1", + "order": 0 + }, + { + "email_address": "s2@example.com", + "name": "Signer 2", + "order": 1 + }, + { + "email_address": "s3@example.com", + "name": "Signer 3", + "order": 2 + } + ], + "test_mode": true +} diff --git a/sandbox/java-v2/pdf-sample.pdf b/sandbox/java-v2/test_fixtures/pdf-sample.pdf similarity index 100% rename from sandbox/java-v2/pdf-sample.pdf rename to sandbox/java-v2/test_fixtures/pdf-sample.pdf diff --git a/sandbox/node/test_fixtures/SignatureRequestCreateEmbeddedRequest.json b/sandbox/node/test_fixtures/SignatureRequestCreateEmbeddedRequest.json new file mode 100644 index 000000000..f9bd157f8 --- /dev/null +++ b/sandbox/node/test_fixtures/SignatureRequestCreateEmbeddedRequest.json @@ -0,0 +1,163 @@ +{ + "allow_decline": true, + "allow_reassign": true, + "attachments": [ + { + "name": "Attachment1", + "signer_index": 1, + "instructions": "Upload your Driver's License", + "required": true + } + ], + "cc_email_addresses": [ + "lawyer1@example.com", + "lawyer2@example.com" + ], + "field_options": { + "date_format": "MM / DD / YYYY" + }, + "form_field_groups": [ + { + "group_id": "radio_group_1", + "group_label": "Radio Group 1", + "requirement": "require_0-1" + } + ], + "form_field_rules": [ + { + "id": "rule_1", + "trigger_operator": "AND", + "triggers": [ + { + "id": "api_id_1", + "operator": "is", + "value": "foo" + } + ], + "actions": [ + { + "field_id": "api_id_2", + "hidden": true, + "type": "change-field-visibility" + } + ] + } + ], + "form_fields_per_document": [ + { + "document_index": 0, + "api_id": "api_id_1", + "name": "field_1", + "type": "text", + "x": 0, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": "0", + "page": 1, + "font_family": "roboto", + "font_size": 11 + }, + { + "document_index": 0, + "api_id": "api_id_2", + "name": "field_2", + "type": "text", + "x": 300, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": 0, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_3", + "name": "field_3", + "type": "dropdown", + "options": [ + "Option 1", + "Option 2", + "Option 3" + ], + "x": 0, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": 1, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_4", + "name": "field_4", + "type": "text", + "x": 300, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": "1", + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_5", + "name": "field_5", + "type": "radio", + "group": "radio_group_1", + "is_checked": true, + "x": 0, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + }, + { + "document_index": 0, + "api_id": "api_id_6", + "name": "field_6", + "type": "radio", + "group": "radio_group_1", + "is_checked": false, + "x": 300, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + } + ], + "message": "Please sign this NDA and then we can discuss more. Let me know if you have any questions.", + "metadata": { + "custom_id": 1234, + "custom_text": "NDA #9" + }, + "signers": [ + { + "email_address": "s1@example.com", + "name": "Signer 1", + "order": 0 + }, + { + "email_address": "s2@example.com", + "name": "Signer 2", + "order": 1 + }, + { + "email_address": "s3@example.com", + "name": "Signer 3", + "order": 2 + } + ], + "test_mode": true +} diff --git a/sandbox/node/test_fixtures/SignatureRequestSendRequest.json b/sandbox/node/test_fixtures/SignatureRequestSendRequest.json new file mode 100644 index 000000000..9560ddd52 --- /dev/null +++ b/sandbox/node/test_fixtures/SignatureRequestSendRequest.json @@ -0,0 +1,163 @@ +{ + "allow_decline": true, + "allow_reassign": true, + "attachments": [ + { + "name": "Attachment1", + "signer_index": 1, + "instructions": "Upload your Driver's License", + "required": true + } + ], + "cc_email_addresses": [ + "lawyer1@example.com", + "lawyer2@example.com" + ], + "field_options": { + "date_format": "DD - MM - YYYY" + }, + "form_field_groups": [ + { + "group_id": "radio_group_1", + "group_label": "Radio Group 1", + "requirement": "require_0-1" + } + ], + "form_field_rules": [ + { + "id": "rule_1", + "trigger_operator": "AND", + "triggers": [ + { + "id": "api_id_1", + "operator": "is", + "value": "foo" + } + ], + "actions": [ + { + "field_id": "api_id_2", + "hidden": true, + "type": "change-field-visibility" + } + ] + } + ], + "form_fields_per_document": [ + { + "document_index": 0, + "api_id": "api_id_1", + "name": "field_1", + "type": "text", + "x": 0, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": "0", + "page": 1, + "font_family": "roboto", + "font_size": 11 + }, + { + "document_index": 0, + "api_id": "api_id_2", + "name": "field_2", + "type": "text", + "x": 300, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": 0, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_3", + "name": "field_3", + "type": "dropdown", + "options": [ + "Option 1", + "Option 2", + "Option 3" + ], + "x": 0, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": 1, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_4", + "name": "field_4", + "type": "text", + "x": 300, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": "1", + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_5", + "name": "field_5", + "type": "radio", + "group": "radio_group_1", + "is_checked": true, + "x": 0, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + }, + { + "document_index": 0, + "api_id": "api_id_6", + "name": "field_6", + "type": "radio", + "group": "radio_group_1", + "is_checked": false, + "x": 300, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + } + ], + "message": "Please sign this NDA and then we can discuss more. Let me know if you\nhave any questions.", + "metadata": { + "custom_id": 1234, + "custom_text": "NDA #9" + }, + "signers": [ + { + "email_address": "s1@example.com", + "name": "Signer 1", + "order": 0 + }, + { + "email_address": "s2@example.com", + "name": "Signer 2", + "order": 1 + }, + { + "email_address": "s3@example.com", + "name": "Signer 3", + "order": 2 + } + ], + "test_mode": true +} diff --git a/sandbox/node/pdf-sample.pdf b/sandbox/node/test_fixtures/pdf-sample.pdf similarity index 100% rename from sandbox/node/pdf-sample.pdf rename to sandbox/node/test_fixtures/pdf-sample.pdf diff --git a/sandbox/php/composer.json b/sandbox/php/composer.json index 0bbf9e28e..ab722a292 100644 --- a/sandbox/php/composer.json +++ b/sandbox/php/composer.json @@ -2,11 +2,15 @@ "name": "dropbox/sign-sandbox", "autoload": { "psr-4": { - "Dropbox\\Sign\\Sandbox\\": "src/" + "Dropbox\\SignSandbox\\Tests\\": "test" } }, "require": { - "dropbox/sign": "*" + "dropbox/sign": "*", + "ext-json": "*" + }, + "require-dev": { + "phpunit/phpunit": "^8.0 || ^9.0" }, "repositories": [ { diff --git a/sandbox/php/test/.config.dist.json b/sandbox/php/test/.config.dist.json new file mode 100644 index 000000000..601c6a5f9 --- /dev/null +++ b/sandbox/php/test/.config.dist.json @@ -0,0 +1,6 @@ +{ + "BASE_URL": "https://api.hellosign.com/v3", + "API_KEY": "", + "CLIENT_ID": "", + "USE_XDEBUG": 0 +} diff --git a/sandbox/php/test/.gitignore b/sandbox/php/test/.gitignore new file mode 100644 index 000000000..a9b8cc8b8 --- /dev/null +++ b/sandbox/php/test/.gitignore @@ -0,0 +1 @@ +.config.json diff --git a/sandbox/php/test/SignatureRequestTest.php b/sandbox/php/test/SignatureRequestTest.php new file mode 100644 index 000000000..052808b36 --- /dev/null +++ b/sandbox/php/test/SignatureRequestTest.php @@ -0,0 +1,151 @@ +client_id = $config['CLIENT_ID']; + + $this->config = new Sign\Configuration(); + $this->config->setUsername($config['API_KEY']); + $this->config->setHost($config['BASE_URL']); + + if ($config['USE_XDEBUG']) { + $cookies = CookieJar::fromArray( + ['XDEBUG_SESSION' => 'xdebug'], + parse_url($config['BASE_URL'], PHP_URL_HOST), + ); + + $this->config->setOptions(['cookies' => $cookies]); + } + } + + public function testSend(): void + { + $signature_request_api = new Sign\Api\SignatureRequestApi($this->config); + + $data = json_decode( + file_get_contents(self::FIXTURES_DIR . '/SignatureRequestSendRequest.json'), + true, + ); + $file = new SplFileObject(self::FIXTURES_DIR . '/pdf-sample.pdf'); + $data['files'] = [$file]; + + $send_request = Sign\Model\SignatureRequestSendRequest::init($data); + + $send_response = $signature_request_api->signatureRequestSend($send_request); + + $this->assertEquals( + $send_request->getFormFieldsPerDocument()[0]->getApiId(), + $send_response->getSignatureRequest()->getCustomFields()[0]->getApiId(), + ); + + $this->assertEquals( + $send_request->getSigners()[0]->getEmailAddress(), + $send_response->getSignatureRequest()->getSignatures()[0]->getSignerEmailAddress(), + ); + $this->assertEquals( + $send_request->getSigners()[1]->getEmailAddress(), + $send_response->getSignatureRequest()->getSignatures()[1]->getSignerEmailAddress(), + ); + $this->assertEquals( + $send_request->getSigners()[2]->getEmailAddress(), + $send_response->getSignatureRequest()->getSignatures()[2]->getSignerEmailAddress(), + ); + + $get_response = $signature_request_api->signatureRequestGet( + $send_response->getSignatureRequest()->getSignatureRequestId(), + ); + + $this->assertSame( + $send_response->getSignatureRequest()->getSignatureRequestId(), + $get_response->getSignatureRequest()->getSignatureRequestId(), + ); + } + + public function testCreateEmbedded(): void + { + $signature_request_api = new Sign\Api\SignatureRequestApi($this->config); + + $data = json_decode( + file_get_contents(self::FIXTURES_DIR . '/SignatureRequestCreateEmbeddedRequest.json'), + true, + ); + $file = new SplFileObject(self::FIXTURES_DIR . '/pdf-sample.pdf'); + $data['files'] = [$file]; + $data['client_id'] = $this->client_id; + + $send_request = Sign\Model\SignatureRequestCreateEmbeddedRequest::init($data); + + $send_response = $signature_request_api->signatureRequestCreateEmbedded($send_request); + + $this->assertEquals( + $send_request->getSigners()[0]->getEmailAddress(), + $send_response->getSignatureRequest()->getSignatures()[0]->getSignerEmailAddress(), + ); + $this->assertEquals( + $send_request->getSigners()[1]->getEmailAddress(), + $send_response->getSignatureRequest()->getSignatures()[1]->getSignerEmailAddress(), + ); + $this->assertEquals( + $send_request->getSigners()[2]->getEmailAddress(), + $send_response->getSignatureRequest()->getSignatures()[2]->getSignerEmailAddress(), + ); + + $embedded_api = new Sign\Api\EmbeddedApi($this->config); + + $get_response = $embedded_api->embeddedSignUrl( + $send_response->getSignatureRequest()->getSignatures()[0]->getSignatureId(), + ); + + $this->assertNotEmpty($get_response->getEmbedded()->getSignUrl()); + } + + public function testSendWithoutFileError(): void + { + $signature_request_api = new Sign\Api\SignatureRequestApi($this->config); + + $data = json_decode( + file_get_contents(self::FIXTURES_DIR . '/SignatureRequestSendRequest.json'), + true, + ); + + $request = Sign\Model\SignatureRequestSendRequest::init($data); + + try { + $response = $signature_request_api->signatureRequestSend($request); + + $this->fail('Should have thrown: ' . print_r($response, true)); + } catch (Sign\ApiException $e) { + $error = $e->getResponseObject(); + + $this->assertEquals('file', $error->getError()->getErrorPath()); + } + } +} diff --git a/sandbox/php/test_fixtures/SignatureRequestCreateEmbeddedRequest.json b/sandbox/php/test_fixtures/SignatureRequestCreateEmbeddedRequest.json new file mode 100644 index 000000000..f9bd157f8 --- /dev/null +++ b/sandbox/php/test_fixtures/SignatureRequestCreateEmbeddedRequest.json @@ -0,0 +1,163 @@ +{ + "allow_decline": true, + "allow_reassign": true, + "attachments": [ + { + "name": "Attachment1", + "signer_index": 1, + "instructions": "Upload your Driver's License", + "required": true + } + ], + "cc_email_addresses": [ + "lawyer1@example.com", + "lawyer2@example.com" + ], + "field_options": { + "date_format": "MM / DD / YYYY" + }, + "form_field_groups": [ + { + "group_id": "radio_group_1", + "group_label": "Radio Group 1", + "requirement": "require_0-1" + } + ], + "form_field_rules": [ + { + "id": "rule_1", + "trigger_operator": "AND", + "triggers": [ + { + "id": "api_id_1", + "operator": "is", + "value": "foo" + } + ], + "actions": [ + { + "field_id": "api_id_2", + "hidden": true, + "type": "change-field-visibility" + } + ] + } + ], + "form_fields_per_document": [ + { + "document_index": 0, + "api_id": "api_id_1", + "name": "field_1", + "type": "text", + "x": 0, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": "0", + "page": 1, + "font_family": "roboto", + "font_size": 11 + }, + { + "document_index": 0, + "api_id": "api_id_2", + "name": "field_2", + "type": "text", + "x": 300, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": 0, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_3", + "name": "field_3", + "type": "dropdown", + "options": [ + "Option 1", + "Option 2", + "Option 3" + ], + "x": 0, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": 1, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_4", + "name": "field_4", + "type": "text", + "x": 300, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": "1", + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_5", + "name": "field_5", + "type": "radio", + "group": "radio_group_1", + "is_checked": true, + "x": 0, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + }, + { + "document_index": 0, + "api_id": "api_id_6", + "name": "field_6", + "type": "radio", + "group": "radio_group_1", + "is_checked": false, + "x": 300, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + } + ], + "message": "Please sign this NDA and then we can discuss more. Let me know if you have any questions.", + "metadata": { + "custom_id": 1234, + "custom_text": "NDA #9" + }, + "signers": [ + { + "email_address": "s1@example.com", + "name": "Signer 1", + "order": 0 + }, + { + "email_address": "s2@example.com", + "name": "Signer 2", + "order": 1 + }, + { + "email_address": "s3@example.com", + "name": "Signer 3", + "order": 2 + } + ], + "test_mode": true +} diff --git a/sandbox/php/test_fixtures/SignatureRequestSendRequest.json b/sandbox/php/test_fixtures/SignatureRequestSendRequest.json new file mode 100644 index 000000000..9560ddd52 --- /dev/null +++ b/sandbox/php/test_fixtures/SignatureRequestSendRequest.json @@ -0,0 +1,163 @@ +{ + "allow_decline": true, + "allow_reassign": true, + "attachments": [ + { + "name": "Attachment1", + "signer_index": 1, + "instructions": "Upload your Driver's License", + "required": true + } + ], + "cc_email_addresses": [ + "lawyer1@example.com", + "lawyer2@example.com" + ], + "field_options": { + "date_format": "DD - MM - YYYY" + }, + "form_field_groups": [ + { + "group_id": "radio_group_1", + "group_label": "Radio Group 1", + "requirement": "require_0-1" + } + ], + "form_field_rules": [ + { + "id": "rule_1", + "trigger_operator": "AND", + "triggers": [ + { + "id": "api_id_1", + "operator": "is", + "value": "foo" + } + ], + "actions": [ + { + "field_id": "api_id_2", + "hidden": true, + "type": "change-field-visibility" + } + ] + } + ], + "form_fields_per_document": [ + { + "document_index": 0, + "api_id": "api_id_1", + "name": "field_1", + "type": "text", + "x": 0, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": "0", + "page": 1, + "font_family": "roboto", + "font_size": 11 + }, + { + "document_index": 0, + "api_id": "api_id_2", + "name": "field_2", + "type": "text", + "x": 300, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": 0, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_3", + "name": "field_3", + "type": "dropdown", + "options": [ + "Option 1", + "Option 2", + "Option 3" + ], + "x": 0, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": 1, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_4", + "name": "field_4", + "type": "text", + "x": 300, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": "1", + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_5", + "name": "field_5", + "type": "radio", + "group": "radio_group_1", + "is_checked": true, + "x": 0, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + }, + { + "document_index": 0, + "api_id": "api_id_6", + "name": "field_6", + "type": "radio", + "group": "radio_group_1", + "is_checked": false, + "x": 300, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + } + ], + "message": "Please sign this NDA and then we can discuss more. Let me know if you\nhave any questions.", + "metadata": { + "custom_id": 1234, + "custom_text": "NDA #9" + }, + "signers": [ + { + "email_address": "s1@example.com", + "name": "Signer 1", + "order": 0 + }, + { + "email_address": "s2@example.com", + "name": "Signer 2", + "order": 1 + }, + { + "email_address": "s3@example.com", + "name": "Signer 3", + "order": 2 + } + ], + "test_mode": true +} diff --git a/sandbox/php/pdf-sample.pdf b/sandbox/php/test_fixtures/pdf-sample.pdf similarity index 100% rename from sandbox/php/pdf-sample.pdf rename to sandbox/php/test_fixtures/pdf-sample.pdf diff --git a/sandbox/python/test_fixtures/SignatureRequestCreateEmbeddedRequest.json b/sandbox/python/test_fixtures/SignatureRequestCreateEmbeddedRequest.json new file mode 100644 index 000000000..f9bd157f8 --- /dev/null +++ b/sandbox/python/test_fixtures/SignatureRequestCreateEmbeddedRequest.json @@ -0,0 +1,163 @@ +{ + "allow_decline": true, + "allow_reassign": true, + "attachments": [ + { + "name": "Attachment1", + "signer_index": 1, + "instructions": "Upload your Driver's License", + "required": true + } + ], + "cc_email_addresses": [ + "lawyer1@example.com", + "lawyer2@example.com" + ], + "field_options": { + "date_format": "MM / DD / YYYY" + }, + "form_field_groups": [ + { + "group_id": "radio_group_1", + "group_label": "Radio Group 1", + "requirement": "require_0-1" + } + ], + "form_field_rules": [ + { + "id": "rule_1", + "trigger_operator": "AND", + "triggers": [ + { + "id": "api_id_1", + "operator": "is", + "value": "foo" + } + ], + "actions": [ + { + "field_id": "api_id_2", + "hidden": true, + "type": "change-field-visibility" + } + ] + } + ], + "form_fields_per_document": [ + { + "document_index": 0, + "api_id": "api_id_1", + "name": "field_1", + "type": "text", + "x": 0, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": "0", + "page": 1, + "font_family": "roboto", + "font_size": 11 + }, + { + "document_index": 0, + "api_id": "api_id_2", + "name": "field_2", + "type": "text", + "x": 300, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": 0, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_3", + "name": "field_3", + "type": "dropdown", + "options": [ + "Option 1", + "Option 2", + "Option 3" + ], + "x": 0, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": 1, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_4", + "name": "field_4", + "type": "text", + "x": 300, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": "1", + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_5", + "name": "field_5", + "type": "radio", + "group": "radio_group_1", + "is_checked": true, + "x": 0, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + }, + { + "document_index": 0, + "api_id": "api_id_6", + "name": "field_6", + "type": "radio", + "group": "radio_group_1", + "is_checked": false, + "x": 300, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + } + ], + "message": "Please sign this NDA and then we can discuss more. Let me know if you have any questions.", + "metadata": { + "custom_id": 1234, + "custom_text": "NDA #9" + }, + "signers": [ + { + "email_address": "s1@example.com", + "name": "Signer 1", + "order": 0 + }, + { + "email_address": "s2@example.com", + "name": "Signer 2", + "order": 1 + }, + { + "email_address": "s3@example.com", + "name": "Signer 3", + "order": 2 + } + ], + "test_mode": true +} diff --git a/sandbox/python/test_fixtures/SignatureRequestSendRequest.json b/sandbox/python/test_fixtures/SignatureRequestSendRequest.json new file mode 100644 index 000000000..9560ddd52 --- /dev/null +++ b/sandbox/python/test_fixtures/SignatureRequestSendRequest.json @@ -0,0 +1,163 @@ +{ + "allow_decline": true, + "allow_reassign": true, + "attachments": [ + { + "name": "Attachment1", + "signer_index": 1, + "instructions": "Upload your Driver's License", + "required": true + } + ], + "cc_email_addresses": [ + "lawyer1@example.com", + "lawyer2@example.com" + ], + "field_options": { + "date_format": "DD - MM - YYYY" + }, + "form_field_groups": [ + { + "group_id": "radio_group_1", + "group_label": "Radio Group 1", + "requirement": "require_0-1" + } + ], + "form_field_rules": [ + { + "id": "rule_1", + "trigger_operator": "AND", + "triggers": [ + { + "id": "api_id_1", + "operator": "is", + "value": "foo" + } + ], + "actions": [ + { + "field_id": "api_id_2", + "hidden": true, + "type": "change-field-visibility" + } + ] + } + ], + "form_fields_per_document": [ + { + "document_index": 0, + "api_id": "api_id_1", + "name": "field_1", + "type": "text", + "x": 0, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": "0", + "page": 1, + "font_family": "roboto", + "font_size": 11 + }, + { + "document_index": 0, + "api_id": "api_id_2", + "name": "field_2", + "type": "text", + "x": 300, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": 0, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_3", + "name": "field_3", + "type": "dropdown", + "options": [ + "Option 1", + "Option 2", + "Option 3" + ], + "x": 0, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": 1, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_4", + "name": "field_4", + "type": "text", + "x": 300, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": "1", + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_5", + "name": "field_5", + "type": "radio", + "group": "radio_group_1", + "is_checked": true, + "x": 0, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + }, + { + "document_index": 0, + "api_id": "api_id_6", + "name": "field_6", + "type": "radio", + "group": "radio_group_1", + "is_checked": false, + "x": 300, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + } + ], + "message": "Please sign this NDA and then we can discuss more. Let me know if you\nhave any questions.", + "metadata": { + "custom_id": 1234, + "custom_text": "NDA #9" + }, + "signers": [ + { + "email_address": "s1@example.com", + "name": "Signer 1", + "order": 0 + }, + { + "email_address": "s2@example.com", + "name": "Signer 2", + "order": 1 + }, + { + "email_address": "s3@example.com", + "name": "Signer 3", + "order": 2 + } + ], + "test_mode": true +} diff --git a/sandbox/python/pdf-sample.pdf b/sandbox/python/test_fixtures/pdf-sample.pdf similarity index 100% rename from sandbox/python/pdf-sample.pdf rename to sandbox/python/test_fixtures/pdf-sample.pdf diff --git a/sandbox/ruby/test_fixtures/SignatureRequestCreateEmbeddedRequest.json b/sandbox/ruby/test_fixtures/SignatureRequestCreateEmbeddedRequest.json new file mode 100644 index 000000000..f9bd157f8 --- /dev/null +++ b/sandbox/ruby/test_fixtures/SignatureRequestCreateEmbeddedRequest.json @@ -0,0 +1,163 @@ +{ + "allow_decline": true, + "allow_reassign": true, + "attachments": [ + { + "name": "Attachment1", + "signer_index": 1, + "instructions": "Upload your Driver's License", + "required": true + } + ], + "cc_email_addresses": [ + "lawyer1@example.com", + "lawyer2@example.com" + ], + "field_options": { + "date_format": "MM / DD / YYYY" + }, + "form_field_groups": [ + { + "group_id": "radio_group_1", + "group_label": "Radio Group 1", + "requirement": "require_0-1" + } + ], + "form_field_rules": [ + { + "id": "rule_1", + "trigger_operator": "AND", + "triggers": [ + { + "id": "api_id_1", + "operator": "is", + "value": "foo" + } + ], + "actions": [ + { + "field_id": "api_id_2", + "hidden": true, + "type": "change-field-visibility" + } + ] + } + ], + "form_fields_per_document": [ + { + "document_index": 0, + "api_id": "api_id_1", + "name": "field_1", + "type": "text", + "x": 0, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": "0", + "page": 1, + "font_family": "roboto", + "font_size": 11 + }, + { + "document_index": 0, + "api_id": "api_id_2", + "name": "field_2", + "type": "text", + "x": 300, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": 0, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_3", + "name": "field_3", + "type": "dropdown", + "options": [ + "Option 1", + "Option 2", + "Option 3" + ], + "x": 0, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": 1, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_4", + "name": "field_4", + "type": "text", + "x": 300, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": "1", + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_5", + "name": "field_5", + "type": "radio", + "group": "radio_group_1", + "is_checked": true, + "x": 0, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + }, + { + "document_index": 0, + "api_id": "api_id_6", + "name": "field_6", + "type": "radio", + "group": "radio_group_1", + "is_checked": false, + "x": 300, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + } + ], + "message": "Please sign this NDA and then we can discuss more. Let me know if you have any questions.", + "metadata": { + "custom_id": 1234, + "custom_text": "NDA #9" + }, + "signers": [ + { + "email_address": "s1@example.com", + "name": "Signer 1", + "order": 0 + }, + { + "email_address": "s2@example.com", + "name": "Signer 2", + "order": 1 + }, + { + "email_address": "s3@example.com", + "name": "Signer 3", + "order": 2 + } + ], + "test_mode": true +} diff --git a/sandbox/ruby/test_fixtures/SignatureRequestSendRequest.json b/sandbox/ruby/test_fixtures/SignatureRequestSendRequest.json new file mode 100644 index 000000000..9560ddd52 --- /dev/null +++ b/sandbox/ruby/test_fixtures/SignatureRequestSendRequest.json @@ -0,0 +1,163 @@ +{ + "allow_decline": true, + "allow_reassign": true, + "attachments": [ + { + "name": "Attachment1", + "signer_index": 1, + "instructions": "Upload your Driver's License", + "required": true + } + ], + "cc_email_addresses": [ + "lawyer1@example.com", + "lawyer2@example.com" + ], + "field_options": { + "date_format": "DD - MM - YYYY" + }, + "form_field_groups": [ + { + "group_id": "radio_group_1", + "group_label": "Radio Group 1", + "requirement": "require_0-1" + } + ], + "form_field_rules": [ + { + "id": "rule_1", + "trigger_operator": "AND", + "triggers": [ + { + "id": "api_id_1", + "operator": "is", + "value": "foo" + } + ], + "actions": [ + { + "field_id": "api_id_2", + "hidden": true, + "type": "change-field-visibility" + } + ] + } + ], + "form_fields_per_document": [ + { + "document_index": 0, + "api_id": "api_id_1", + "name": "field_1", + "type": "text", + "x": 0, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": "0", + "page": 1, + "font_family": "roboto", + "font_size": 11 + }, + { + "document_index": 0, + "api_id": "api_id_2", + "name": "field_2", + "type": "text", + "x": 300, + "y": 0, + "width": 120, + "height": 30, + "required": true, + "signer": 0, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_3", + "name": "field_3", + "type": "dropdown", + "options": [ + "Option 1", + "Option 2", + "Option 3" + ], + "x": 0, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": 1, + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_4", + "name": "field_4", + "type": "text", + "x": 300, + "y": 200, + "width": 120, + "height": 30, + "required": true, + "signer": "1", + "page": 1, + "font_size": 12 + }, + { + "document_index": 0, + "api_id": "api_id_5", + "name": "field_5", + "type": "radio", + "group": "radio_group_1", + "is_checked": true, + "x": 0, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + }, + { + "document_index": 0, + "api_id": "api_id_6", + "name": "field_6", + "type": "radio", + "group": "radio_group_1", + "is_checked": false, + "x": 300, + "y": 400, + "width": 100, + "height": 16, + "required": false, + "signer": "2", + "page": 1 + } + ], + "message": "Please sign this NDA and then we can discuss more. Let me know if you\nhave any questions.", + "metadata": { + "custom_id": 1234, + "custom_text": "NDA #9" + }, + "signers": [ + { + "email_address": "s1@example.com", + "name": "Signer 1", + "order": 0 + }, + { + "email_address": "s2@example.com", + "name": "Signer 2", + "order": 1 + }, + { + "email_address": "s3@example.com", + "name": "Signer 3", + "order": 2 + } + ], + "test_mode": true +} diff --git a/sandbox/ruby/pdf-sample.pdf b/sandbox/ruby/test_fixtures/pdf-sample.pdf similarity index 100% rename from sandbox/ruby/pdf-sample.pdf rename to sandbox/ruby/test_fixtures/pdf-sample.pdf diff --git a/sdks/php/.gitignore b/sdks/php/.gitignore index 3f10c0389..12f85db8f 100644 --- a/sdks/php/.gitignore +++ b/sdks/php/.gitignore @@ -14,7 +14,9 @@ composer.phar # PHPUnit cache .phpunit.result.cache +# CUSTOM - BEGIN .composer .openapi-generator git_push.sh composer.lock +# CUSTOM - END diff --git a/sdks/php/.php-cs-fixer.dist.php b/sdks/php/.php-cs-fixer.dist.php new file mode 100644 index 000000000..a8ff32efd --- /dev/null +++ b/sdks/php/.php-cs-fixer.dist.php @@ -0,0 +1,105 @@ +in(__DIR__) + ->exclude('vendor') + ->exclude('test') + ->exclude('tests') + ->exclude('bin') + ->exclude('docs') + ->exclude('examples') + ->exclude('templates') + ->exclude('test_fixtures') +; + +$config = new PhpCsFixer\Config(); +$config->setParallelConfig( + PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect() +); +return $config->setRules([ + '@PhpCsFixer' => true, + '@Symfony' => true, + '@DoctrineAnnotation' => true, + 'binary_operator_spaces' => [ + 'operators' => [ + '=>' => null, + ], + ], + 'blank_line_before_statement' => [ + 'statements' => [], + ], + 'blank_line_after_opening_tag' => false, + 'cast_spaces' => [ + 'space' => 'none', + ], + 'class_definition' => [ + 'inline_constructor_arguments' => false, + 'space_before_parenthesis' => true, + ], + 'concat_space' => [ + 'spacing' => 'one', + ], + 'nullable_type_declaration_for_default_null_value' => false, + 'declare_parentheses' => true, + 'echo_tag_syntax' => [ + 'format' => 'short', + 'shorten_simple_statements_only' => true, + ], + 'fully_qualified_strict_types' => true, + 'global_namespace_import' => true, + 'general_phpdoc_annotation_remove' => [ + 'annotations' => [ + 'author', 'package', 'subpackage', 'version', + ], + ], + 'increment_style' => false, + 'multiline_whitespace_before_semicolons' => [ + 'strategy' => 'no_multi_line', + ], + 'ordered_imports' => [ + 'imports_order' => [ + 'class', 'function', 'const', + ], + 'sort_algorithm' => 'alpha', + ], + 'no_superfluous_phpdoc_tags' => [ + 'allow_mixed' => true, + 'allow_unused_params' => true, + 'remove_inheritdoc' => true, + ], + 'phpdoc_align' => [ + 'tags' => [ + 'method', 'param', 'property', 'return', 'type', 'var', + ], + ], + 'phpdoc_line_span' => [ + 'property' => 'single', + ], + 'phpdoc_separation' => false, + 'phpdoc_summary' => false, + 'phpdoc_to_comment' => false, + 'phpdoc_to_param_type' => [ + 'scalar_types' => true, + 'union_types' => false, + ], + 'php_unit_internal_class' => false, + 'php_unit_test_class_requires_covers' => false, + 'single_line_throw' => false, + 'statement_indentation' => [ + 'stick_comment_to_next_continuous_control_statement' => false, + ], + 'visibility_required' => [ + 'elements' => ['method', 'property'], + ], + 'yoda_style' => false, + 'trailing_comma_in_multiline' => [ + 'after_heredoc' => true, + ], +]) + ->setFinder($finder) + ->setRiskyAllowed(true) +; diff --git a/sdks/php/.php-cs-fixer.php b/sdks/php/.php-cs-fixer.php deleted file mode 100644 index 4f602dac6..000000000 --- a/sdks/php/.php-cs-fixer.php +++ /dev/null @@ -1,22 +0,0 @@ -in(__DIR__) - ->exclude(['bin', 'docs', 'examples', 'templates', 'legacy']); - -$config = new PhpCsFixer\Config(); -return $config->setRules([ - '@Symfony' => true, - 'concat_space' => ['spacing' => 'one'], - 'global_namespace_import' => true, - 'fully_qualified_strict_types' => true, - 'increment_style' => false, - 'phpdoc_align' => ['align' => 'left'], - 'phpdoc_separation' => false, - 'phpdoc_summary' => false, - 'phpdoc_to_param_type' => true, - 'single_line_throw' => false, - 'yoda_style' => false, -]) - ->setFinder($finder) - ->setRiskyAllowed(true); diff --git a/sdks/php/README.md b/sdks/php/README.md index f694462fa..b68ace90a 100644 --- a/sdks/php/README.md +++ b/sdks/php/README.md @@ -59,7 +59,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ``` -Then run `composer install`. +Then run `composer install` Alternatively, install directly with @@ -212,6 +212,7 @@ All URIs are relative to *https://api.hellosign.com/v3* | *UnclaimedDraftApi* | [**unclaimedDraftCreateEmbeddedWithTemplate**](docs/Api/UnclaimedDraftApi.md#unclaimeddraftcreateembeddedwithtemplate) | **POST** /unclaimed_draft/create_embedded_with_template | Create Embedded Unclaimed Draft with Template | | *UnclaimedDraftApi* | [**unclaimedDraftEditAndResend**](docs/Api/UnclaimedDraftApi.md#unclaimeddrafteditandresend) | **POST** /unclaimed_draft/edit_and_resend/{signature_request_id} | Edit and Resend Unclaimed Draft | + ## Models - [AccountCreateRequest](docs/Model/AccountCreateRequest.md) @@ -400,6 +401,7 @@ All URIs are relative to *https://api.hellosign.com/v3* ## Authorization + ### api_key - **Type**: HTTP basic authentication @@ -427,5 +429,6 @@ apisupport@hellosign.com This PHP package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: - API version: `3.0.0` - - Package version: `1.5-dev` + - Package version: `1.6-dev` + - Generator version: `7.8.0` - Build package: `org.openapitools.codegen.languages.PhpClientCodegen` diff --git a/sdks/php/VERSION b/sdks/php/VERSION index 6f3dd2f48..78ca9a102 100644 --- a/sdks/php/VERSION +++ b/sdks/php/VERSION @@ -1 +1 @@ -1.5-dev +1.6-dev diff --git a/sdks/php/bin/php-8 b/sdks/php/bin/php-8 new file mode 100755 index 000000000..78acc6d73 --- /dev/null +++ b/sdks/php/bin/php-8 @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +# Warning: You should run this from rootless Docker (or Podman, or other) + +set -e + +DIR=$(cd `dirname $0` && pwd) +ROOT_DIR="${DIR}/.." +WORKING_DIR="/app/php" + +docker run --rm \ + -v "${ROOT_DIR}:${WORKING_DIR}" \ + -v "dropbox-sign-sdk-composer-cache:/.composer" \ + -w "${WORKING_DIR}" \ + -u root:root \ + jtreminio/php:8.1 "$@" + + exit 0 diff --git a/sdks/php/bin/replace b/sdks/php/bin/replace index ddf95444e..232cc7b3b 100755 --- a/sdks/php/bin/replace +++ b/sdks/php/bin/replace @@ -16,4 +16,8 @@ perl -pi -e 's#@return Model\\(.*)\|\\Dropbox\\Sign\\Model\\ErrorResponse#@retur "${ROOT_DIR}/src/Api/"*.php perl -pi -e 's#@return SplFileObject\|\\Dropbox\\Sign\\Model\\ErrorResponse#@return SplFileObject#g' \ "${ROOT_DIR}/src/Api/"*.php +perl -pi -e 's#@return Model\\(.*)\|Model\\ErrorResponse#@return Model\\$1#g' \ + "${ROOT_DIR}/src/Api/"*.php +perl -pi -e 's#@return SplFileObject\|Model\\ErrorResponse#@return SplFileObject#g' \ + "${ROOT_DIR}/src/Api/"*.php printf "\n" diff --git a/sdks/php/composer.json b/sdks/php/composer.json index 8d7844d8f..347c72797 100644 --- a/sdks/php/composer.json +++ b/sdks/php/composer.json @@ -1,6 +1,6 @@ { "name": "dropbox/sign", - "description": "Official Dropbox Sign APIv3 PHP SDK", + "description": "Dropbox Sign v3 API", "keywords": [ "openapitools", "openapi-generator", @@ -13,18 +13,12 @@ "dropboxsign" ], "homepage": "https://hellosign.com", - "license": [ - "MIT" - ], + "license": "MIT", "authors": [ { "name": "Dropbox Sign", "homepage": "https://hellosign.com", "email": "apisupport@hellosign.com" - }, - { - "name": "OpenAPI-Generator contributors", - "homepage": "https://openapi-generator.tech" } ], "require": { @@ -37,13 +31,11 @@ }, "require-dev": { "phpunit/phpunit": "^8.0 || ^9.0", - "friendsofphp/php-cs-fixer": "3.4.*", + "friendsofphp/php-cs-fixer": "^3.5", "symfony/yaml": "^5.4" }, "autoload": { - "psr-4": { - "Dropbox\\Sign\\": "src/" - } + "psr-4": { "Dropbox\\Sign\\" : "src/" } }, "autoload-dev": { "psr-4": { "Dropbox\\Sign\\Test\\" : "test/" } diff --git a/sdks/php/docs/Api/AccountApi.md b/sdks/php/docs/Api/AccountApi.md index 7e850df59..9c8e8c9f0 100644 --- a/sdks/php/docs/Api/AccountApi.md +++ b/sdks/php/docs/Api/AccountApi.md @@ -15,7 +15,6 @@ All URIs are relative to https://api.hellosign.com/v3. ```php accountCreate($account_create_request): \Dropbox\Sign\Model\AccountCreateResponse ``` - Create Account Creates a new Dropbox Sign Account that is associated with the specified `email_address`. @@ -79,7 +78,6 @@ try { ```php accountGet($account_id, $email_address): \Dropbox\Sign\Model\AccountGetResponse ``` - Get Account Returns the properties and settings of your Account. @@ -141,7 +139,6 @@ try { ```php accountUpdate($account_update_request): \Dropbox\Sign\Model\AccountGetResponse ``` - Update Account Updates the properties and settings of your Account. Currently only allows for updates to the [Callback URL](/api/reference/tag/Callbacks-and-Events) and locale. @@ -205,7 +202,6 @@ try { ```php accountVerify($account_verify_request): \Dropbox\Sign\Model\AccountVerifyResponse ``` - Verify Account Verifies whether an Dropbox Sign Account exists for the given email address. diff --git a/sdks/php/docs/Api/ApiAppApi.md b/sdks/php/docs/Api/ApiAppApi.md index e330f9946..a591601b2 100644 --- a/sdks/php/docs/Api/ApiAppApi.md +++ b/sdks/php/docs/Api/ApiAppApi.md @@ -16,7 +16,6 @@ All URIs are relative to https://api.hellosign.com/v3. ```php apiAppCreate($api_app_create_request): \Dropbox\Sign\Model\ApiAppGetResponse ``` - Create API App Creates a new API App. @@ -97,7 +96,6 @@ try { ```php apiAppDelete($client_id) ``` - Delete API App Deletes an API App. Can only be invoked for apps you own. @@ -159,7 +157,6 @@ void (empty response body) ```php apiAppGet($client_id): \Dropbox\Sign\Model\ApiAppGetResponse ``` - Get API App Returns an object with information about an API App. @@ -222,7 +219,6 @@ try { ```php apiAppList($page, $page_size): \Dropbox\Sign\Model\ApiAppListResponse ``` - List API Apps Returns a list of API Apps that are accessible by you. If you are on a team with an Admin or Developer role, this list will include apps owned by teammates. @@ -287,7 +283,6 @@ try { ```php apiAppUpdate($client_id, $api_app_update_request): \Dropbox\Sign\Model\ApiAppGetResponse ``` - Update API App Updates an existing API App. Can only be invoked for apps you own. Only the fields you provide will be updated. If you wish to clear an existing optional field, provide an empty string. diff --git a/sdks/php/docs/Api/BulkSendJobApi.md b/sdks/php/docs/Api/BulkSendJobApi.md index b53d3074c..ede4f3415 100644 --- a/sdks/php/docs/Api/BulkSendJobApi.md +++ b/sdks/php/docs/Api/BulkSendJobApi.md @@ -13,7 +13,6 @@ All URIs are relative to https://api.hellosign.com/v3. ```php bulkSendJobGet($bulk_send_job_id, $page, $page_size): \Dropbox\Sign\Model\BulkSendJobGetResponse ``` - Get Bulk Send Job Returns the status of the BulkSendJob and its SignatureRequests specified by the `bulk_send_job_id` parameter. @@ -78,7 +77,6 @@ try { ```php bulkSendJobList($page, $page_size): \Dropbox\Sign\Model\BulkSendJobListResponse ``` - List Bulk Send Jobs Returns a list of BulkSendJob that you can access. diff --git a/sdks/php/docs/Api/EmbeddedApi.md b/sdks/php/docs/Api/EmbeddedApi.md index 111eefb3b..8b1acfbc4 100644 --- a/sdks/php/docs/Api/EmbeddedApi.md +++ b/sdks/php/docs/Api/EmbeddedApi.md @@ -13,7 +13,6 @@ All URIs are relative to https://api.hellosign.com/v3. ```php embeddedEditUrl($template_id, $embedded_edit_url_request): \Dropbox\Sign\Model\EmbeddedEditUrlResponse ``` - Get Embedded Template Edit URL Retrieves an embedded object containing a template url that can be opened in an iFrame. Note that only templates created via the embedded template process are available to be edited with this endpoint. @@ -81,7 +80,6 @@ try { ```php embeddedSignUrl($signature_id): \Dropbox\Sign\Model\EmbeddedSignUrlResponse ``` - Get Embedded Sign URL Retrieves an embedded object containing a signature url that can be opened in an iFrame. Note that templates created via the embedded template process will only be accessible through the API. diff --git a/sdks/php/docs/Api/FaxLineApi.md b/sdks/php/docs/Api/FaxLineApi.md index 677d605e9..1bb340d36 100644 --- a/sdks/php/docs/Api/FaxLineApi.md +++ b/sdks/php/docs/Api/FaxLineApi.md @@ -18,7 +18,6 @@ All URIs are relative to https://api.hellosign.com/v3. ```php faxLineAddUser($fax_line_add_user_request): \Dropbox\Sign\Model\FaxLineResponse ``` - Add Fax Line User Grants a user access to the specified Fax Line. @@ -80,7 +79,6 @@ try { ```php faxLineAreaCodeGet($country, $state, $province, $city): \Dropbox\Sign\Model\FaxLineAreaCodeGetResponse ``` - Get Available Fax Line Area Codes Returns a response with the area codes available for a given state/provice and city. @@ -141,7 +139,6 @@ try { ```php faxLineCreate($fax_line_create_request): \Dropbox\Sign\Model\FaxLineResponse ``` - Purchase Fax Line Purchases a new Fax Line. @@ -203,7 +200,6 @@ try { ```php faxLineDelete($fax_line_delete_request) ``` - Delete Fax Line Deletes the specified Fax Line from the subscription. @@ -263,7 +259,6 @@ void (empty response body) ```php faxLineGet($number): \Dropbox\Sign\Model\FaxLineResponse ``` - Get Fax Line Returns the properties and settings of a Fax Line. @@ -321,7 +316,6 @@ try { ```php faxLineList($account_id, $page, $page_size, $show_team_lines): \Dropbox\Sign\Model\FaxLineListResponse ``` - List Fax Lines Returns the properties and settings of multiple Fax Lines. @@ -382,7 +376,6 @@ try { ```php faxLineRemoveUser($fax_line_remove_user_request): \Dropbox\Sign\Model\FaxLineResponse ``` - Remove Fax Line Access Removes a user's access to the specified Fax Line. diff --git a/sdks/php/docs/Api/OAuthApi.md b/sdks/php/docs/Api/OAuthApi.md index 9b63ca7fd..854b4b7a0 100644 --- a/sdks/php/docs/Api/OAuthApi.md +++ b/sdks/php/docs/Api/OAuthApi.md @@ -13,7 +13,6 @@ All URIs are relative to https://api.hellosign.com/v3. ```php oauthTokenGenerate($o_auth_token_generate_request): \Dropbox\Sign\Model\OAuthTokenResponse ``` - OAuth Token Generate Once you have retrieved the code from the user callback, you will need to exchange it for an access token via a backend call. @@ -74,7 +73,6 @@ No authorization required ```php oauthTokenRefresh($o_auth_token_refresh_request): \Dropbox\Sign\Model\OAuthTokenResponse ``` - OAuth Token Refresh Access tokens are only valid for a given period of time (typically one hour) for security reasons. Whenever acquiring an new access token its TTL is also given (see `expires_in`), along with a refresh token that can be used to acquire a new access token after the current one has expired. diff --git a/sdks/php/docs/Api/ReportApi.md b/sdks/php/docs/Api/ReportApi.md index 95afd1fd0..285a20e83 100644 --- a/sdks/php/docs/Api/ReportApi.md +++ b/sdks/php/docs/Api/ReportApi.md @@ -12,7 +12,6 @@ All URIs are relative to https://api.hellosign.com/v3. ```php reportCreate($report_create_request): \Dropbox\Sign\Model\ReportCreateResponse ``` - Create Report Request the creation of one or more report(s). When the report(s) have been generated, you will receive an email (one per requested report type) containing a link to download the report as a CSV file. The requested date range may be up to 12 months in duration, and `start_date` must not be more than 10 years in the past. diff --git a/sdks/php/docs/Api/SignatureRequestApi.md b/sdks/php/docs/Api/SignatureRequestApi.md index 078cc8769..373d1215c 100644 --- a/sdks/php/docs/Api/SignatureRequestApi.md +++ b/sdks/php/docs/Api/SignatureRequestApi.md @@ -27,7 +27,6 @@ All URIs are relative to https://api.hellosign.com/v3. ```php signatureRequestBulkCreateEmbeddedWithTemplate($signature_request_bulk_create_embedded_with_template_request): \Dropbox\Sign\Model\BulkSendJobSendResponse ``` - Embedded Bulk Send with Template Creates BulkSendJob which sends up to 250 SignatureRequests in bulk based off of the provided Template(s) specified with the `template_ids` parameter to be signed in an embedded iFrame. These embedded signature requests can only be signed in embedded iFrames whereas normal signature requests can only be signed on Dropbox Sign. **NOTE:** Only available for Standard plan and higher. @@ -126,7 +125,6 @@ try { ```php signatureRequestBulkSendWithTemplate($signature_request_bulk_send_with_template_request): \Dropbox\Sign\Model\BulkSendJobSendResponse ``` - Bulk Send with Template Creates BulkSendJob which sends up to 250 SignatureRequests in bulk based off of the provided Template(s) specified with the `template_ids` parameter. **NOTE:** Only available for Standard plan and higher. @@ -227,7 +225,6 @@ try { ```php signatureRequestCancel($signature_request_id) ``` - Cancel Incomplete Signature Request Cancels an incomplete signature request. This action is **not reversible**. The request will be canceled and signers will no longer be able to sign. If they try to access the signature request they will receive a HTTP 410 status code indicating that the resource has been deleted. Cancelation is asynchronous and a successful call to this endpoint will return an empty 200 OK response if the signature request is eligible to be canceled and has been successfully queued. This 200 OK response does not indicate a successful cancelation of the signature request itself. The cancelation is confirmed via the `signature_request_canceled` event. It is recommended that a [callback handler](/api/reference/tag/Callbacks-and-Events) be implemented to listen for the `signature_request_canceled` event. This callback will be sent only when the cancelation has completed successfully. If a callback handler has been configured and the event has not been received within 60 minutes of making the call, check the status of the request in the [API Dashboard](https://app.hellosign.com/apidashboard) and retry the cancelation if necessary. To be eligible for cancelation, a signature request must have been sent successfully, must not yet have been signed by all signers, and you must either be the sender or own the API app under which it was sent. A partially signed signature request can be canceled. **NOTE:** To remove your access to a completed signature request, use the endpoint: `POST /signature_request/remove/[:signature_request_id]`. @@ -289,7 +286,6 @@ void (empty response body) ```php signatureRequestCreateEmbedded($signature_request_create_embedded_request): \Dropbox\Sign\Model\SignatureRequestGetResponse ``` - Create Embedded Signature Request Creates a new SignatureRequest with the submitted documents to be signed in an embedded iFrame. If form_fields_per_document is not specified, a signature page will be affixed where all signers will be required to add their signature, signifying their agreement to all contained documents. Note that embedded signature requests can only be signed in embedded iFrames whereas normal signature requests can only be signed on Dropbox Sign. @@ -381,7 +377,6 @@ try { ```php signatureRequestCreateEmbeddedWithTemplate($signature_request_create_embedded_with_template_request): \Dropbox\Sign\Model\SignatureRequestGetResponse ``` - Create Embedded Signature Request with Template Creates a new SignatureRequest based on the given Template(s) to be signed in an embedded iFrame. Note that embedded signature requests can only be signed in embedded iFrames whereas normal signature requests can only be signed on Dropbox Sign. @@ -463,7 +458,6 @@ try { ```php signatureRequestFiles($signature_request_id, $file_type): \SplFileObject ``` - Download Files Obtain a copy of the current documents specified by the `signature_request_id` parameter. Returns a PDF or ZIP file. If the files are currently being prepared, a status code of `409` will be returned instead. @@ -528,7 +522,6 @@ try { ```php signatureRequestFilesAsDataUri($signature_request_id): \Dropbox\Sign\Model\FileResponseDataUri ``` - Download Files as Data Uri Obtain a copy of the current documents specified by the `signature_request_id` parameter. Returns a JSON object with a `data_uri` representing the base64 encoded file (PDFs only). If the files are currently being prepared, a status code of `409` will be returned instead. @@ -591,7 +584,6 @@ try { ```php signatureRequestFilesAsFileUrl($signature_request_id, $force_download): \Dropbox\Sign\Model\FileResponse ``` - Download Files as File Url Obtain a copy of the current documents specified by the `signature_request_id` parameter. Returns a JSON object with a url to the file (PDFs only). If the files are currently being prepared, a status code of `409` will be returned instead. @@ -655,7 +647,6 @@ try { ```php signatureRequestGet($signature_request_id): \Dropbox\Sign\Model\SignatureRequestGetResponse ``` - Get Signature Request Returns the status of the SignatureRequest specified by the `signature_request_id` parameter. @@ -718,7 +709,6 @@ try { ```php signatureRequestList($account_id, $page, $page_size, $query): \Dropbox\Sign\Model\SignatureRequestListResponse ``` - List Signature Requests Returns a list of SignatureRequests that you can access. This includes SignatureRequests you have sent as well as received, but not ones that you have been CCed on. Take a look at our [search guide](/api/reference/search/) to learn more about querying signature requests. @@ -785,7 +775,6 @@ try { ```php signatureRequestReleaseHold($signature_request_id): \Dropbox\Sign\Model\SignatureRequestGetResponse ``` - Release On-Hold Signature Request Releases a held SignatureRequest that was claimed and prepared from an [UnclaimedDraft](/api/reference/tag/Unclaimed-Draft). The owner of the Draft must indicate at Draft creation that the SignatureRequest created from the Draft should be held. Releasing the SignatureRequest will send requests to all signers. @@ -848,7 +837,6 @@ try { ```php signatureRequestRemind($signature_request_id, $signature_request_remind_request): \Dropbox\Sign\Model\SignatureRequestGetResponse ``` - Send Request Reminder Sends an email to the signer reminding them to sign the signature request. You cannot send a reminder within 1 hour of the last reminder that was sent. This includes manual AND automatic reminders. **NOTE:** This action can **not** be used with embedded signature requests. @@ -915,7 +903,6 @@ try { ```php signatureRequestRemove($signature_request_id) ``` - Remove Signature Request Access Removes your access to a completed signature request. This action is **not reversible**. The signature request must be fully executed by all parties (signed or declined to sign). Other parties will continue to maintain access to the completed signature request document(s). Unlike /signature_request/cancel, this endpoint is synchronous and your access will be immediately removed. Upon successful removal, this endpoint will return a 200 OK response. @@ -974,7 +961,6 @@ void (empty response body) ```php signatureRequestSend($signature_request_send_request): \Dropbox\Sign\Model\SignatureRequestGetResponse ``` - Send Signature Request Creates and sends a new SignatureRequest with the submitted documents. If `form_fields_per_document` is not specified, a signature page will be affixed where all signers will be required to add their signature, signifying their agreement to all contained documents. @@ -1073,7 +1059,6 @@ try { ```php signatureRequestSendWithTemplate($signature_request_send_with_template_request): \Dropbox\Sign\Model\SignatureRequestGetResponse ``` - Send with Template Creates and sends a new SignatureRequest based off of the Template(s) specified with the `template_ids` parameter. @@ -1166,7 +1151,6 @@ try { ```php signatureRequestUpdate($signature_request_id, $signature_request_update_request): \Dropbox\Sign\Model\SignatureRequestGetResponse ``` - Update Signature Request Updates the email address and/or the name for a given signer on a signature request. You can listen for the `signature_request_email_bounce` event on your app or account to detect bounced emails, and respond with this method. Updating the email address of a signer will generate a new `signature_id` value. **NOTE:** This action cannot be performed on a signature request with an appended signature page. diff --git a/sdks/php/docs/Api/TeamApi.md b/sdks/php/docs/Api/TeamApi.md index 7705304ad..1f46c6b3f 100644 --- a/sdks/php/docs/Api/TeamApi.md +++ b/sdks/php/docs/Api/TeamApi.md @@ -21,7 +21,6 @@ All URIs are relative to https://api.hellosign.com/v3. ```php teamAddMember($team_add_member_request, $team_id): \Dropbox\Sign\Model\TeamGetResponse ``` - Add User to Team Invites a user (specified using the `email_address` parameter) to your Team. If the user does not currently have a Dropbox Sign Account, a new one will be created for them. If a user is already a part of another Team, a `team_invite_failed` error will be returned. @@ -86,7 +85,6 @@ try { ```php teamCreate($team_create_request): \Dropbox\Sign\Model\TeamGetResponse ``` - Create Team Creates a new Team and makes you a member. You must not currently belong to a Team to invoke. @@ -150,7 +148,6 @@ try { ```php teamDelete() ``` - Delete Team Deletes your Team. Can only be invoked when you have a Team with only one member (yourself). @@ -208,7 +205,6 @@ void (empty response body) ```php teamGet(): \Dropbox\Sign\Model\TeamGetResponse ``` - Get Team Returns information about your Team as well as a list of its members. If you do not belong to a Team, a 404 error with an error_name of \"not_found\" will be returned. @@ -267,7 +263,6 @@ try { ```php teamInfo($team_id): \Dropbox\Sign\Model\TeamGetInfoResponse ``` - Get Team Info Provides information about a team. @@ -328,7 +323,6 @@ try { ```php teamInvites($email_address): \Dropbox\Sign\Model\TeamInvitesResponse ``` - List Team Invites Provides a list of team invites (and their roles). @@ -391,7 +385,6 @@ try { ```php teamMembers($team_id, $page, $page_size): \Dropbox\Sign\Model\TeamMembersResponse ``` - List Team Members Provides a paginated list of members (and their roles) that belong to a given team. @@ -456,7 +449,6 @@ try { ```php teamRemoveMember($team_remove_member_request): \Dropbox\Sign\Model\TeamGetResponse ``` - Remove User from Team Removes the provided user Account from your Team. If the Account had an outstanding invitation to your Team, the invitation will be expired. If you choose to transfer documents from the removed Account to an Account provided in the `new_owner_email_address` parameter (available only for Enterprise plans), the response status code will be 201, which indicates that your request has been queued but not fully executed. @@ -521,7 +513,6 @@ try { ```php teamSubTeams($team_id, $page, $page_size): \Dropbox\Sign\Model\TeamSubTeamsResponse ``` - List Sub Teams Provides a paginated list of sub teams that belong to a given team. @@ -586,7 +577,6 @@ try { ```php teamUpdate($team_update_request): \Dropbox\Sign\Model\TeamGetResponse ``` - Update Team Updates the name of your Team. diff --git a/sdks/php/docs/Api/TemplateApi.md b/sdks/php/docs/Api/TemplateApi.md index c81bc7b74..3331db8dd 100644 --- a/sdks/php/docs/Api/TemplateApi.md +++ b/sdks/php/docs/Api/TemplateApi.md @@ -22,7 +22,6 @@ All URIs are relative to https://api.hellosign.com/v3. ```php templateAddUser($template_id, $template_add_user_request): \Dropbox\Sign\Model\TemplateGetResponse ``` - Add User to Template Gives the specified Account access to the specified Template. The specified Account must be a part of your Team. @@ -89,7 +88,6 @@ try { ```php templateCreate($template_create_request): \Dropbox\Sign\Model\TemplateCreateResponse ``` - Create Template Creates a template that can then be used. @@ -181,7 +179,6 @@ try { ```php templateCreateEmbeddedDraft($template_create_embedded_draft_request): \Dropbox\Sign\Model\TemplateCreateEmbeddedDraftResponse ``` - Create Embedded Template Draft The first step in an embedded template workflow. Creates a draft template that can then be further set up in the template 'edit' stage. @@ -273,7 +270,6 @@ try { ```php templateDelete($template_id) ``` - Delete Template Completely deletes the template specified from the account. @@ -335,7 +331,6 @@ void (empty response body) ```php templateFiles($template_id, $file_type): \SplFileObject ``` - Get Template Files Obtain a copy of the current documents specified by the `template_id` parameter. Returns a PDF or ZIP file. If the files are currently being prepared, a status code of `409` will be returned instead. In this case please wait for the `template_created` callback event. @@ -400,7 +395,6 @@ try { ```php templateFilesAsDataUri($template_id): \Dropbox\Sign\Model\FileResponseDataUri ``` - Get Template Files as Data Uri Obtain a copy of the current documents specified by the `template_id` parameter. Returns a JSON object with a `data_uri` representing the base64 encoded file (PDFs only). If the files are currently being prepared, a status code of `409` will be returned instead. In this case please wait for the `template_created` callback event. @@ -463,7 +457,6 @@ try { ```php templateFilesAsFileUrl($template_id, $force_download): \Dropbox\Sign\Model\FileResponse ``` - Get Template Files as File Url Obtain a copy of the current documents specified by the `template_id` parameter. Returns a JSON object with a url to the file (PDFs only). If the files are currently being prepared, a status code of `409` will be returned instead. In this case please wait for the `template_created` callback event. @@ -527,7 +520,6 @@ try { ```php templateGet($template_id): \Dropbox\Sign\Model\TemplateGetResponse ``` - Get Template Returns the Template specified by the `template_id` parameter. @@ -590,7 +582,6 @@ try { ```php templateList($account_id, $page, $page_size, $query): \Dropbox\Sign\Model\TemplateListResponse ``` - List Templates Returns a list of the Templates that are accessible by you. Take a look at our [search guide](/api/reference/search/) to learn more about querying templates. @@ -656,7 +647,6 @@ try { ```php templateRemoveUser($template_id, $template_remove_user_request): \Dropbox\Sign\Model\TemplateGetResponse ``` - Remove User from Template Removes the specified Account's access to the specified Template. @@ -723,7 +713,6 @@ try { ```php templateUpdateFiles($template_id, $template_update_files_request): \Dropbox\Sign\Model\TemplateUpdateFilesResponse ``` - Update Template Files Overlays a new file with the overlay of an existing template. The new file(s) must: 1. have the same or higher page count 2. the same orientation as the file(s) being replaced. This will not overwrite or in any way affect the existing template. Both the existing template and new template will be available for use after executing this endpoint. Also note that this will decrement your template quota. Overlaying new files is asynchronous and a successful call to this endpoint will return 200 OK response if the request passes initial validation checks. It is recommended that a callback be implemented to listen for the callback event. A `template_created` event will be sent when the files are updated or a `template_error` event will be sent if there was a problem while updating the files. If a callback handler has been configured and the event has not been received within 60 minutes of making the call, check the status of the request in the API dashboard and retry the request if necessary. If the page orientation or page count is different from the original template document, we will notify you with a `template_error` [callback event](https://app.hellosign.com/api/eventsAndCallbacksWalkthrough). diff --git a/sdks/php/docs/Api/UnclaimedDraftApi.md b/sdks/php/docs/Api/UnclaimedDraftApi.md index c0dd2c438..a2b2f4236 100644 --- a/sdks/php/docs/Api/UnclaimedDraftApi.md +++ b/sdks/php/docs/Api/UnclaimedDraftApi.md @@ -15,7 +15,6 @@ All URIs are relative to https://api.hellosign.com/v3. ```php unclaimedDraftCreate($unclaimed_draft_create_request): \Dropbox\Sign\Model\UnclaimedDraftCreateResponse ``` - Create Unclaimed Draft Creates a new Draft that can be claimed using the claim URL. The first authenticated user to access the URL will claim the Draft and will be shown either the \"Sign and send\" or the \"Request signature\" page with the Draft loaded. Subsequent access to the claim URL will result in a 404. @@ -114,7 +113,6 @@ try { ```php unclaimedDraftCreateEmbedded($unclaimed_draft_create_embedded_request): \Dropbox\Sign\Model\UnclaimedDraftCreateResponse ``` - Create Embedded Unclaimed Draft Creates a new Draft that can be claimed and used in an embedded iFrame. The first authenticated user to access the URL will claim the Draft and will be shown the \"Request signature\" page with the Draft loaded. Subsequent access to the claim URL will result in a `404`. For this embedded endpoint the `requester_email_address` parameter is required. **NOTE:** Embedded unclaimed drafts can only be accessed in embedded iFrames whereas normal drafts can be used and accessed on Dropbox Sign. @@ -181,7 +179,6 @@ try { ```php unclaimedDraftCreateEmbeddedWithTemplate($unclaimed_draft_create_embedded_with_template_request): \Dropbox\Sign\Model\UnclaimedDraftCreateResponse ``` - Create Embedded Unclaimed Draft with Template Creates a new Draft with a previously saved template(s) that can be claimed and used in an embedded iFrame. The first authenticated user to access the URL will claim the Draft and will be shown the \"Request signature\" page with the Draft loaded. Subsequent access to the claim URL will result in a `404`. For this embedded endpoint the `requester_email_address` parameter is required. **NOTE:** Embedded unclaimed drafts can only be accessed in embedded iFrames whereas normal drafts can be used and accessed on Dropbox Sign. @@ -259,7 +256,6 @@ try { ```php unclaimedDraftEditAndResend($signature_request_id, $unclaimed_draft_edit_and_resend_request): \Dropbox\Sign\Model\UnclaimedDraftCreateResponse ``` - Edit and Resend Unclaimed Draft Creates a new signature request from an embedded request that can be edited prior to being sent to the recipients. Parameter `test_mode` can be edited prior to request. Signers can be edited in embedded editor. Requester's email address will remain unchanged if `requester_email_address` parameter is not set. **NOTE:** Embedded unclaimed drafts can only be accessed in embedded iFrames whereas normal drafts can be used and accessed on Dropbox Sign. diff --git a/sdks/php/openapi-config.yaml b/sdks/php/openapi-config.yaml index d93266974..773838fe8 100644 --- a/sdks/php/openapi-config.yaml +++ b/sdks/php/openapi-config.yaml @@ -4,11 +4,18 @@ typeMappings: additionalProperties: packageName: dropbox/sign packageVersion: "^1.3.0" - artifactVersion: 1.5-dev + artifactVersion: 1.6-dev invokerPackage: "Dropbox\\Sign" sortModelPropertiesByRequiredFlag: true srcBasePath: src phpVersion: 7.4 + composerPackageName: "dropbox/sign" + artifactUrl: "https://hellosign.com" + licenseName: "MIT" + developerOrganization: "Dropbox Sign" + developerOrganizationUrl: "https://hellosign.com" + developerOrganizationEmail: "apisupport@hellosign.com" + useCustomTemplateCode: true files: EventCallbackHelper.mustache: templateType: SupportingFiles diff --git a/sdks/php/phpunit.xml.dist b/sdks/php/phpunit.xml.dist index b04c85f79..d53f74070 100644 --- a/sdks/php/phpunit.xml.dist +++ b/sdks/php/phpunit.xml.dist @@ -8,8 +8,7 @@ - ./test/Api - ./test/Model + ./test diff --git a/sdks/php/run-build b/sdks/php/run-build index 2818bb63b..f2d645a92 100755 --- a/sdks/php/run-build +++ b/sdks/php/run-build @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# see https://github.com/OpenAPITools/openapi-generator/tree/ef882a4e6c6066007952de3bd7013f9940dc0de7/modules/openapi-generator/src/main/resources/php +# see https://github.com/OpenAPITools/openapi-generator/tree/v7.8.0/modules/openapi-generator/src/main/resources/php set -e @@ -10,7 +10,7 @@ WORKING_DIR="/app/php" docker run --rm \ -v "${DIR}/:/local" \ -v "${DIR}/openapi-sdk.yaml:/local/openapi-sdk.yaml" \ - openapitools/openapi-generator-cli:v5.3.0 generate \ + openapitools/openapi-generator-cli:v7.8.0 generate \ -i "/local/openapi-sdk.yaml" \ -c "/local/openapi-config.yaml" \ -t "/local/templates" \ @@ -22,10 +22,10 @@ bash "${DIR}/bin/php" composer install printf "\n" printf "Adding examples to Docs ...\n" -bash "${DIR}/bin/php" ./bin/generate-examples.php +bash "${DIR}/bin/php-8" ./bin/generate-examples.php printf "Running php-cs-fixer ...\n" -bash "${DIR}/bin/php" ./vendor/bin/php-cs-fixer fix --verbose +bash "${DIR}/bin/php-8" ./vendor/bin/php-cs-fixer fix --verbose printf "Replacing strings ...\n" docker run --rm \ diff --git a/sdks/php/src/Api/AccountApi.php b/sdks/php/src/Api/AccountApi.php index 9b2517429..cfdc96f11 100644 --- a/sdks/php/src/Api/AccountApi.php +++ b/sdks/php/src/Api/AccountApi.php @@ -4,7 +4,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -16,7 +15,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -36,11 +35,11 @@ use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Promise; -use GuzzleHttp\Psr7; +use GuzzleHttp\Psr7\MultipartStream; +use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; -use GuzzleHttp\Utils; use InvalidArgumentException; +use JsonException; use Psr\Http\Message\ResponseInterface; use RuntimeException; @@ -48,34 +47,41 @@ * AccountApi Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ class AccountApi { - /** - * @var ClientInterface - */ + /** @var ClientInterface */ protected $client; - /** - * @var Configuration - */ + /** @var Configuration */ protected $config; - /** - * @var HeaderSelector - */ + /** @var HeaderSelector */ protected $headerSelector; - /** - * @var int Host index - */ + /** @var int Host index */ protected $hostIndex; /** - * @var ResponseInterface|null + * @var string[] * */ + public const contentTypes = [ + 'accountCreate' => [ + 'application/json', + ], + 'accountGet' => [ + 'application/json', + ], + 'accountUpdate' => [ + 'application/json', + ], + 'accountVerify' => [ + 'application/json', + ], + ]; + + /** @var ResponseInterface|null */ protected $response; /** @@ -97,6 +103,7 @@ public function __construct( * Set the host index * * @param int $hostIndex Host index (required) + * @deprecated To be made private in the future */ public function setHostIndex(int $hostIndex): void { @@ -107,6 +114,7 @@ public function setHostIndex(int $hostIndex): void * Get the host index * * @return int Host index + * @deprecated To be made private in the future */ public function getHostIndex() { @@ -136,14 +144,13 @@ public function getResponse() * * @param Model\AccountCreateRequest $account_create_request account_create_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\AccountCreateResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function accountCreate(Model\AccountCreateRequest $account_create_request) { list($response) = $this->accountCreateWithHttpInfo($account_create_request); - return $response; } @@ -153,14 +160,16 @@ public function accountCreate(Model\AccountCreateRequest $account_create_request * Create Account * * @param Model\AccountCreateRequest $account_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['accountCreate'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\AccountCreateResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::accountCreate. This method will eventually become unavailable */ - public function accountCreateWithHttpInfo(Model\AccountCreateRequest $account_create_request) + public function accountCreateWithHttpInfo(Model\AccountCreateRequest $account_create_request, string $contentType = self::contentTypes['accountCreate'][0]) { - $request = $this->accountCreateRequest($account_create_request); + $request = $this->accountCreateRequest($account_create_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -170,14 +179,14 @@ public function accountCreateWithHttpInfo(Model\AccountCreateRequest $account_cr } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -190,51 +199,73 @@ public function accountCreateWithHttpInfo(Model\AccountCreateRequest $account_cr sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\AccountCreateResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\AccountCreateResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\AccountCreateResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\AccountCreateResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\AccountCreateResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\AccountCreateResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -243,28 +274,19 @@ public function accountCreateWithHttpInfo(Model\AccountCreateRequest $account_cr $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\AccountCreateResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\AccountCreateResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -275,13 +297,15 @@ public function accountCreateWithHttpInfo(Model\AccountCreateRequest $account_cr * Create Account * * @param Model\AccountCreateRequest $account_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['accountCreate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::accountCreate. This method will eventually become unavailable */ - public function accountCreateAsync(Model\AccountCreateRequest $account_create_request) + public function accountCreateAsync(Model\AccountCreateRequest $account_create_request, string $contentType = self::contentTypes['accountCreate'][0]) { - return $this->accountCreateAsyncWithHttpInfo($account_create_request) + return $this->accountCreateAsyncWithHttpInfo($account_create_request, $contentType) ->then( function ($response) { return $response[0]; @@ -295,23 +319,28 @@ function ($response) { * Create Account * * @param Model\AccountCreateRequest $account_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['accountCreate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::accountCreate. This method will eventually become unavailable */ - public function accountCreateAsyncWithHttpInfo(Model\AccountCreateRequest $account_create_request) + public function accountCreateAsyncWithHttpInfo(Model\AccountCreateRequest $account_create_request, string $contentType = self::contentTypes['accountCreate'][0]) { $returnType = '\Dropbox\Sign\Model\AccountCreateResponse'; - $request = $this->accountCreateRequest($account_create_request); + $request = $this->accountCreateRequest($account_create_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -331,7 +360,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -341,11 +370,13 @@ function ($exception) { * Create request for operation 'accountCreate' * * @param Model\AccountCreateRequest $account_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['accountCreate'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::accountCreate. This method will eventually become unavailable */ - public function accountCreateRequest(Model\AccountCreateRequest $account_create_request) + public function accountCreateRequest(Model\AccountCreateRequest $account_create_request, string $contentType = self::contentTypes['accountCreate'][0]) { // verify the required parameter 'account_create_request' is set if ($account_create_request === null || (is_array($account_create_request) && count($account_create_request) === 0)) { @@ -355,9 +386,11 @@ public function accountCreateRequest(Model\AccountCreateRequest $account_create_ } $resourcePath = '/account/create'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $account_create_request @@ -365,21 +398,17 @@ public function accountCreateRequest(Model\AccountCreateRequest $account_create_ $multipart = !empty($formParams); - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($account_create_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($account_create_request)); } else { $httpBody = $account_create_request; } @@ -398,22 +427,22 @@ public function accountCreateRequest(Model\AccountCreateRequest $account_create_ // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $account_create_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -437,11 +466,11 @@ public function accountCreateRequest(Model\AccountCreateRequest $account_create_ $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -452,17 +481,16 @@ public function accountCreateRequest(Model\AccountCreateRequest $account_create_ * * Get Account * - * @param string $account_id `account_id` or `email_address` is required. If both are provided, the account id prevails. The ID of the Account. (optional) + * @param string $account_id `account_id` or `email_address` is required. If both are provided, the account id prevails. The ID of the Account. (optional) * @param string $email_address `account_id` or `email_address` is required, If both are provided, the account id prevails. The email address of the Account. (optional) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\AccountGetResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function accountGet(string $account_id = null, string $email_address = null) { list($response) = $this->accountGetWithHttpInfo($account_id, $email_address); - return $response; } @@ -471,16 +499,18 @@ public function accountGet(string $account_id = null, string $email_address = nu * * Get Account * - * @param string $account_id `account_id` or `email_address` is required. If both are provided, the account id prevails. The ID of the Account. (optional) + * @param string $account_id `account_id` or `email_address` is required. If both are provided, the account id prevails. The ID of the Account. (optional) * @param string $email_address `account_id` or `email_address` is required, If both are provided, the account id prevails. The email address of the Account. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['accountGet'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\AccountGetResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::accountGet. This method will eventually become unavailable */ - public function accountGetWithHttpInfo(string $account_id = null, string $email_address = null) + public function accountGetWithHttpInfo(string $account_id = null, string $email_address = null, string $contentType = self::contentTypes['accountGet'][0]) { - $request = $this->accountGetRequest($account_id, $email_address); + $request = $this->accountGetRequest($account_id, $email_address, $contentType); try { $options = $this->createHttpClientOption(); @@ -490,14 +520,14 @@ public function accountGetWithHttpInfo(string $account_id = null, string $email_ } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -510,51 +540,73 @@ public function accountGetWithHttpInfo(string $account_id = null, string $email_ sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\AccountGetResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\AccountGetResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\AccountGetResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\AccountGetResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\AccountGetResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\AccountGetResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -563,28 +615,19 @@ public function accountGetWithHttpInfo(string $account_id = null, string $email_ $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\AccountGetResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\AccountGetResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -594,15 +637,17 @@ public function accountGetWithHttpInfo(string $account_id = null, string $email_ * * Get Account * - * @param string $account_id `account_id` or `email_address` is required. If both are provided, the account id prevails. The ID of the Account. (optional) + * @param string $account_id `account_id` or `email_address` is required. If both are provided, the account id prevails. The ID of the Account. (optional) * @param string $email_address `account_id` or `email_address` is required, If both are provided, the account id prevails. The email address of the Account. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['accountGet'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::accountGet. This method will eventually become unavailable */ - public function accountGetAsync(string $account_id = null, string $email_address = null) + public function accountGetAsync(string $account_id = null, string $email_address = null, string $contentType = self::contentTypes['accountGet'][0]) { - return $this->accountGetAsyncWithHttpInfo($account_id, $email_address) + return $this->accountGetAsyncWithHttpInfo($account_id, $email_address, $contentType) ->then( function ($response) { return $response[0]; @@ -615,25 +660,30 @@ function ($response) { * * Get Account * - * @param string $account_id `account_id` or `email_address` is required. If both are provided, the account id prevails. The ID of the Account. (optional) + * @param string $account_id `account_id` or `email_address` is required. If both are provided, the account id prevails. The ID of the Account. (optional) * @param string $email_address `account_id` or `email_address` is required, If both are provided, the account id prevails. The email address of the Account. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['accountGet'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::accountGet. This method will eventually become unavailable */ - public function accountGetAsyncWithHttpInfo(string $account_id = null, string $email_address = null) + public function accountGetAsyncWithHttpInfo(string $account_id = null, string $email_address = null, string $contentType = self::contentTypes['accountGet'][0]) { $returnType = '\Dropbox\Sign\Model\AccountGetResponse'; - $request = $this->accountGetRequest($account_id, $email_address); + $request = $this->accountGetRequest($account_id, $email_address, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -653,7 +703,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -662,53 +712,47 @@ function ($exception) { /** * Create request for operation 'accountGet' * - * @param string $account_id `account_id` or `email_address` is required. If both are provided, the account id prevails. The ID of the Account. (optional) + * @param string $account_id `account_id` or `email_address` is required. If both are provided, the account id prevails. The ID of the Account. (optional) * @param string $email_address `account_id` or `email_address` is required, If both are provided, the account id prevails. The email address of the Account. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['accountGet'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::accountGet. This method will eventually become unavailable */ - public function accountGetRequest(string $account_id = null, string $email_address = null) + public function accountGetRequest(string $account_id = null, string $email_address = null, string $contentType = self::contentTypes['accountGet'][0]) { $resourcePath = '/account'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // query params - if ($account_id !== null) { - if ('form' === 'form' && is_array($account_id)) { - foreach ($account_id as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['account_id'] = $account_id; - } - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $account_id, + 'account_id', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); // query params - if ($email_address !== null) { - if ('form' === 'form' && is_array($email_address)) { - foreach ($email_address as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['email_address'] = $email_address; - } - } - - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $email_address, + 'email_address', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -726,18 +770,19 @@ public function accountGetRequest(string $account_id = null, string $email_addre // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -761,11 +806,11 @@ public function accountGetRequest(string $account_id = null, string $email_addre $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'GET', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -778,14 +823,13 @@ public function accountGetRequest(string $account_id = null, string $email_addre * * @param Model\AccountUpdateRequest $account_update_request account_update_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\AccountGetResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function accountUpdate(Model\AccountUpdateRequest $account_update_request) { list($response) = $this->accountUpdateWithHttpInfo($account_update_request); - return $response; } @@ -795,14 +839,16 @@ public function accountUpdate(Model\AccountUpdateRequest $account_update_request * Update Account * * @param Model\AccountUpdateRequest $account_update_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['accountUpdate'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\AccountGetResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::accountUpdate. This method will eventually become unavailable */ - public function accountUpdateWithHttpInfo(Model\AccountUpdateRequest $account_update_request) + public function accountUpdateWithHttpInfo(Model\AccountUpdateRequest $account_update_request, string $contentType = self::contentTypes['accountUpdate'][0]) { - $request = $this->accountUpdateRequest($account_update_request); + $request = $this->accountUpdateRequest($account_update_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -812,14 +858,14 @@ public function accountUpdateWithHttpInfo(Model\AccountUpdateRequest $account_up } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -832,51 +878,73 @@ public function accountUpdateWithHttpInfo(Model\AccountUpdateRequest $account_up sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\AccountGetResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\AccountGetResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\AccountGetResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\AccountGetResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\AccountGetResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\AccountGetResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -885,28 +953,19 @@ public function accountUpdateWithHttpInfo(Model\AccountUpdateRequest $account_up $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\AccountGetResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\AccountGetResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -917,13 +976,15 @@ public function accountUpdateWithHttpInfo(Model\AccountUpdateRequest $account_up * Update Account * * @param Model\AccountUpdateRequest $account_update_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['accountUpdate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::accountUpdate. This method will eventually become unavailable */ - public function accountUpdateAsync(Model\AccountUpdateRequest $account_update_request) + public function accountUpdateAsync(Model\AccountUpdateRequest $account_update_request, string $contentType = self::contentTypes['accountUpdate'][0]) { - return $this->accountUpdateAsyncWithHttpInfo($account_update_request) + return $this->accountUpdateAsyncWithHttpInfo($account_update_request, $contentType) ->then( function ($response) { return $response[0]; @@ -937,23 +998,28 @@ function ($response) { * Update Account * * @param Model\AccountUpdateRequest $account_update_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['accountUpdate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::accountUpdate. This method will eventually become unavailable */ - public function accountUpdateAsyncWithHttpInfo(Model\AccountUpdateRequest $account_update_request) + public function accountUpdateAsyncWithHttpInfo(Model\AccountUpdateRequest $account_update_request, string $contentType = self::contentTypes['accountUpdate'][0]) { $returnType = '\Dropbox\Sign\Model\AccountGetResponse'; - $request = $this->accountUpdateRequest($account_update_request); + $request = $this->accountUpdateRequest($account_update_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -973,7 +1039,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -983,11 +1049,13 @@ function ($exception) { * Create request for operation 'accountUpdate' * * @param Model\AccountUpdateRequest $account_update_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['accountUpdate'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::accountUpdate. This method will eventually become unavailable */ - public function accountUpdateRequest(Model\AccountUpdateRequest $account_update_request) + public function accountUpdateRequest(Model\AccountUpdateRequest $account_update_request, string $contentType = self::contentTypes['accountUpdate'][0]) { // verify the required parameter 'account_update_request' is set if ($account_update_request === null || (is_array($account_update_request) && count($account_update_request) === 0)) { @@ -997,9 +1065,11 @@ public function accountUpdateRequest(Model\AccountUpdateRequest $account_update_ } $resourcePath = '/account'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $account_update_request @@ -1007,21 +1077,17 @@ public function accountUpdateRequest(Model\AccountUpdateRequest $account_update_ $multipart = !empty($formParams); - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($account_update_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($account_update_request)); } else { $httpBody = $account_update_request; } @@ -1040,22 +1106,22 @@ public function accountUpdateRequest(Model\AccountUpdateRequest $account_update_ // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $account_update_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -1079,11 +1145,11 @@ public function accountUpdateRequest(Model\AccountUpdateRequest $account_update_ $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'PUT', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1096,14 +1162,13 @@ public function accountUpdateRequest(Model\AccountUpdateRequest $account_update_ * * @param Model\AccountVerifyRequest $account_verify_request account_verify_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\AccountVerifyResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function accountVerify(Model\AccountVerifyRequest $account_verify_request) { list($response) = $this->accountVerifyWithHttpInfo($account_verify_request); - return $response; } @@ -1113,14 +1178,16 @@ public function accountVerify(Model\AccountVerifyRequest $account_verify_request * Verify Account * * @param Model\AccountVerifyRequest $account_verify_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['accountVerify'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\AccountVerifyResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::accountVerify. This method will eventually become unavailable */ - public function accountVerifyWithHttpInfo(Model\AccountVerifyRequest $account_verify_request) + public function accountVerifyWithHttpInfo(Model\AccountVerifyRequest $account_verify_request, string $contentType = self::contentTypes['accountVerify'][0]) { - $request = $this->accountVerifyRequest($account_verify_request); + $request = $this->accountVerifyRequest($account_verify_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -1130,14 +1197,14 @@ public function accountVerifyWithHttpInfo(Model\AccountVerifyRequest $account_ve } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -1150,51 +1217,73 @@ public function accountVerifyWithHttpInfo(Model\AccountVerifyRequest $account_ve sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\AccountVerifyResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\AccountVerifyResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\AccountVerifyResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\AccountVerifyResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\AccountVerifyResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\AccountVerifyResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -1203,28 +1292,19 @@ public function accountVerifyWithHttpInfo(Model\AccountVerifyRequest $account_ve $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\AccountVerifyResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\AccountVerifyResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -1235,13 +1315,15 @@ public function accountVerifyWithHttpInfo(Model\AccountVerifyRequest $account_ve * Verify Account * * @param Model\AccountVerifyRequest $account_verify_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['accountVerify'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::accountVerify. This method will eventually become unavailable */ - public function accountVerifyAsync(Model\AccountVerifyRequest $account_verify_request) + public function accountVerifyAsync(Model\AccountVerifyRequest $account_verify_request, string $contentType = self::contentTypes['accountVerify'][0]) { - return $this->accountVerifyAsyncWithHttpInfo($account_verify_request) + return $this->accountVerifyAsyncWithHttpInfo($account_verify_request, $contentType) ->then( function ($response) { return $response[0]; @@ -1255,23 +1337,28 @@ function ($response) { * Verify Account * * @param Model\AccountVerifyRequest $account_verify_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['accountVerify'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::accountVerify. This method will eventually become unavailable */ - public function accountVerifyAsyncWithHttpInfo(Model\AccountVerifyRequest $account_verify_request) + public function accountVerifyAsyncWithHttpInfo(Model\AccountVerifyRequest $account_verify_request, string $contentType = self::contentTypes['accountVerify'][0]) { $returnType = '\Dropbox\Sign\Model\AccountVerifyResponse'; - $request = $this->accountVerifyRequest($account_verify_request); + $request = $this->accountVerifyRequest($account_verify_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -1291,7 +1378,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -1301,11 +1388,13 @@ function ($exception) { * Create request for operation 'accountVerify' * * @param Model\AccountVerifyRequest $account_verify_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['accountVerify'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::accountVerify. This method will eventually become unavailable */ - public function accountVerifyRequest(Model\AccountVerifyRequest $account_verify_request) + public function accountVerifyRequest(Model\AccountVerifyRequest $account_verify_request, string $contentType = self::contentTypes['accountVerify'][0]) { // verify the required parameter 'account_verify_request' is set if ($account_verify_request === null || (is_array($account_verify_request) && count($account_verify_request) === 0)) { @@ -1315,9 +1404,11 @@ public function accountVerifyRequest(Model\AccountVerifyRequest $account_verify_ } $resourcePath = '/account/verify'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $account_verify_request @@ -1325,21 +1416,17 @@ public function accountVerifyRequest(Model\AccountVerifyRequest $account_verify_ $multipart = !empty($formParams); - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($account_verify_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($account_verify_request)); } else { $httpBody = $account_verify_request; } @@ -1358,22 +1445,22 @@ public function accountVerifyRequest(Model\AccountVerifyRequest $account_verify_ // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $account_verify_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -1397,11 +1484,11 @@ public function accountVerifyRequest(Model\AccountVerifyRequest $account_verify_ $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1410,8 +1497,8 @@ public function accountVerifyRequest(Model\AccountVerifyRequest $account_verify_ /** * Create http client option * - * @throws RuntimeException on file opening failure * @return array of http client options + * @throws RuntimeException on file opening failure */ protected function createHttpClientOption() { @@ -1425,4 +1512,66 @@ protected function createHttpClientOption() return $options; } + + /** + * @return object|array|null + */ + private function handleRangeCodeResponse( + ResponseInterface $response, + string $rangeCode, + string $returnDataType + ) { + $statusCode = $response->getStatusCode(); + $rangeCodeLeft = (int)(substr($rangeCode, 0, 1) . '00'); + $rangeCodeRight = (int)(substr($rangeCode, 0, 1) . '99'); + + if ( + $statusCode < $rangeCodeLeft + || $statusCode > $rangeCodeRight + ) { + return null; + } + + if ($returnDataType === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + } + + return [ + ObjectSerializer::deserialize($content, $returnDataType, []), + $statusCode, + $response->getHeaders(), + ]; + } + + /** + * @return object|array|null + */ + private function handleRangeCodeException( + ApiException $e, + string $rangeCode, + string $exceptionDataType + ): bool { + $statusCode = $e->getCode(); + $rangeCodeLeft = (int)(substr($rangeCode, 0, 1) . '00'); + $rangeCodeRight = (int)(substr($rangeCode, 0, 1) . '99'); + + if ( + $statusCode < $rangeCodeLeft + || $statusCode > $rangeCodeRight + ) { + return false; + } + + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + $exceptionDataType, + $e->getResponseHeaders() + ); + + $e->setResponseObject($data); + + return true; + } } diff --git a/sdks/php/src/Api/ApiAppApi.php b/sdks/php/src/Api/ApiAppApi.php index 2f158ac84..07dd3db63 100644 --- a/sdks/php/src/Api/ApiAppApi.php +++ b/sdks/php/src/Api/ApiAppApi.php @@ -4,7 +4,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -16,7 +15,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -36,11 +35,11 @@ use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Promise; -use GuzzleHttp\Psr7; +use GuzzleHttp\Psr7\MultipartStream; +use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; -use GuzzleHttp\Utils; use InvalidArgumentException; +use JsonException; use Psr\Http\Message\ResponseInterface; use RuntimeException; @@ -48,34 +47,46 @@ * ApiAppApi Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ class ApiAppApi { - /** - * @var ClientInterface - */ + /** @var ClientInterface */ protected $client; - /** - * @var Configuration - */ + /** @var Configuration */ protected $config; - /** - * @var HeaderSelector - */ + /** @var HeaderSelector */ protected $headerSelector; - /** - * @var int Host index - */ + /** @var int Host index */ protected $hostIndex; /** - * @var ResponseInterface|null + * @var string[] * */ + public const contentTypes = [ + 'apiAppCreate' => [ + 'application/json', + 'multipart/form-data', + ], + 'apiAppDelete' => [ + 'application/json', + ], + 'apiAppGet' => [ + 'application/json', + ], + 'apiAppList' => [ + 'application/json', + ], + 'apiAppUpdate' => [ + 'application/json', + 'multipart/form-data', + ], + ]; + + /** @var ResponseInterface|null */ protected $response; /** @@ -97,6 +108,7 @@ public function __construct( * Set the host index * * @param int $hostIndex Host index (required) + * @deprecated To be made private in the future */ public function setHostIndex(int $hostIndex): void { @@ -107,6 +119,7 @@ public function setHostIndex(int $hostIndex): void * Get the host index * * @return int Host index + * @deprecated To be made private in the future */ public function getHostIndex() { @@ -136,14 +149,13 @@ public function getResponse() * * @param Model\ApiAppCreateRequest $api_app_create_request api_app_create_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\ApiAppGetResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function apiAppCreate(Model\ApiAppCreateRequest $api_app_create_request) { list($response) = $this->apiAppCreateWithHttpInfo($api_app_create_request); - return $response; } @@ -153,14 +165,16 @@ public function apiAppCreate(Model\ApiAppCreateRequest $api_app_create_request) * Create API App * * @param Model\ApiAppCreateRequest $api_app_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiAppCreate'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\ApiAppGetResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::apiAppCreate. This method will eventually become unavailable */ - public function apiAppCreateWithHttpInfo(Model\ApiAppCreateRequest $api_app_create_request) + public function apiAppCreateWithHttpInfo(Model\ApiAppCreateRequest $api_app_create_request, string $contentType = self::contentTypes['apiAppCreate'][0]) { - $request = $this->apiAppCreateRequest($api_app_create_request); + $request = $this->apiAppCreateRequest($api_app_create_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -170,14 +184,14 @@ public function apiAppCreateWithHttpInfo(Model\ApiAppCreateRequest $api_app_crea } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -190,51 +204,73 @@ public function apiAppCreateWithHttpInfo(Model\ApiAppCreateRequest $api_app_crea sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 201) { - if ('\Dropbox\Sign\Model\ApiAppGetResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ApiAppGetResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 201: + if ('\Dropbox\Sign\Model\ApiAppGetResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\ApiAppGetResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ApiAppGetResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\ApiAppGetResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -243,28 +279,19 @@ public function apiAppCreateWithHttpInfo(Model\ApiAppCreateRequest $api_app_crea $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 201) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ApiAppGetResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + switch ($e->getCode()) { + case 201: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\ApiAppGetResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -275,13 +302,15 @@ public function apiAppCreateWithHttpInfo(Model\ApiAppCreateRequest $api_app_crea * Create API App * * @param Model\ApiAppCreateRequest $api_app_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiAppCreate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::apiAppCreate. This method will eventually become unavailable */ - public function apiAppCreateAsync(Model\ApiAppCreateRequest $api_app_create_request) + public function apiAppCreateAsync(Model\ApiAppCreateRequest $api_app_create_request, string $contentType = self::contentTypes['apiAppCreate'][0]) { - return $this->apiAppCreateAsyncWithHttpInfo($api_app_create_request) + return $this->apiAppCreateAsyncWithHttpInfo($api_app_create_request, $contentType) ->then( function ($response) { return $response[0]; @@ -295,23 +324,28 @@ function ($response) { * Create API App * * @param Model\ApiAppCreateRequest $api_app_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiAppCreate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::apiAppCreate. This method will eventually become unavailable */ - public function apiAppCreateAsyncWithHttpInfo(Model\ApiAppCreateRequest $api_app_create_request) + public function apiAppCreateAsyncWithHttpInfo(Model\ApiAppCreateRequest $api_app_create_request, string $contentType = self::contentTypes['apiAppCreate'][0]) { $returnType = '\Dropbox\Sign\Model\ApiAppGetResponse'; - $request = $this->apiAppCreateRequest($api_app_create_request); + $request = $this->apiAppCreateRequest($api_app_create_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -331,7 +365,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -341,11 +375,13 @@ function ($exception) { * Create request for operation 'apiAppCreate' * * @param Model\ApiAppCreateRequest $api_app_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiAppCreate'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::apiAppCreate. This method will eventually become unavailable */ - public function apiAppCreateRequest(Model\ApiAppCreateRequest $api_app_create_request) + public function apiAppCreateRequest(Model\ApiAppCreateRequest $api_app_create_request, string $contentType = self::contentTypes['apiAppCreate'][0]) { // verify the required parameter 'api_app_create_request' is set if ($api_app_create_request === null || (is_array($api_app_create_request) && count($api_app_create_request) === 0)) { @@ -355,9 +391,11 @@ public function apiAppCreateRequest(Model\ApiAppCreateRequest $api_app_create_re } $resourcePath = '/api_app'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $api_app_create_request @@ -365,21 +403,17 @@ public function apiAppCreateRequest(Model\ApiAppCreateRequest $api_app_create_re $multipart = !empty($formParams); - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json', 'multipart/form-data'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($api_app_create_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($api_app_create_request)); } else { $httpBody = $api_app_create_request; } @@ -398,22 +432,22 @@ public function apiAppCreateRequest(Model\ApiAppCreateRequest $api_app_create_re // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $api_app_create_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -437,11 +471,11 @@ public function apiAppCreateRequest(Model\ApiAppCreateRequest $api_app_create_re $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -454,9 +488,8 @@ public function apiAppCreateRequest(Model\ApiAppCreateRequest $api_app_create_re * * @param string $client_id The client id of the API App to delete. (required) * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException - * @return void */ public function apiAppDelete(string $client_id) { @@ -468,15 +501,17 @@ public function apiAppDelete(string $client_id) * * Delete API App * - * @param string $client_id The client id of the API App to delete. (required) + * @param string $client_id The client id of the API App to delete. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiAppDelete'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::apiAppDelete. This method will eventually become unavailable */ - public function apiAppDeleteWithHttpInfo(string $client_id) + public function apiAppDeleteWithHttpInfo(string $client_id, string $contentType = self::contentTypes['apiAppDelete'][0]) { - $request = $this->apiAppDeleteRequest($client_id); + $request = $this->apiAppDeleteRequest($client_id, $contentType); try { $options = $this->createHttpClientOption(); @@ -486,14 +521,14 @@ public function apiAppDeleteWithHttpInfo(string $client_id) } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -506,29 +541,21 @@ public function apiAppDeleteWithHttpInfo(string $client_id) sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } return [null, $statusCode, $response->getHeaders()]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { } - throw $e; } } @@ -538,14 +565,16 @@ public function apiAppDeleteWithHttpInfo(string $client_id) * * Delete API App * - * @param string $client_id The client id of the API App to delete. (required) + * @param string $client_id The client id of the API App to delete. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiAppDelete'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::apiAppDelete. This method will eventually become unavailable */ - public function apiAppDeleteAsync(string $client_id) + public function apiAppDeleteAsync(string $client_id, string $contentType = self::contentTypes['apiAppDelete'][0]) { - return $this->apiAppDeleteAsyncWithHttpInfo($client_id) + return $this->apiAppDeleteAsyncWithHttpInfo($client_id, $contentType) ->then( function ($response) { return $response[0]; @@ -558,15 +587,17 @@ function ($response) { * * Delete API App * - * @param string $client_id The client id of the API App to delete. (required) + * @param string $client_id The client id of the API App to delete. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiAppDelete'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::apiAppDelete. This method will eventually become unavailable */ - public function apiAppDeleteAsyncWithHttpInfo(string $client_id) + public function apiAppDeleteAsyncWithHttpInfo(string $client_id, string $contentType = self::contentTypes['apiAppDelete'][0]) { $returnType = ''; - $request = $this->apiAppDeleteRequest($client_id); + $request = $this->apiAppDeleteRequest($client_id, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -585,7 +616,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -594,12 +625,14 @@ function ($exception) { /** * Create request for operation 'apiAppDelete' * - * @param string $client_id The client id of the API App to delete. (required) + * @param string $client_id The client id of the API App to delete. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiAppDelete'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::apiAppDelete. This method will eventually become unavailable */ - public function apiAppDeleteRequest(string $client_id) + public function apiAppDeleteRequest(string $client_id, string $contentType = self::contentTypes['apiAppDelete'][0]) { // verify the required parameter 'client_id' is set if ($client_id === null || (is_array($client_id) && count($client_id) === 0)) { @@ -609,32 +642,26 @@ public function apiAppDeleteRequest(string $client_id) } $resourcePath = '/api_app/{client_id}'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // path params if ($client_id !== null) { $resourcePath = str_replace( - '{' . 'client_id' . '}', + '{client_id}', ObjectSerializer::toPathValue($client_id), $resourcePath ); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -652,18 +679,19 @@ public function apiAppDeleteRequest(string $client_id) // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -687,11 +715,11 @@ public function apiAppDeleteRequest(string $client_id) $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'DELETE', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -704,14 +732,13 @@ public function apiAppDeleteRequest(string $client_id) * * @param string $client_id The client id of the API App to retrieve. (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\ApiAppGetResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function apiAppGet(string $client_id) { list($response) = $this->apiAppGetWithHttpInfo($client_id); - return $response; } @@ -720,15 +747,17 @@ public function apiAppGet(string $client_id) * * Get API App * - * @param string $client_id The client id of the API App to retrieve. (required) + * @param string $client_id The client id of the API App to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiAppGet'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\ApiAppGetResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::apiAppGet. This method will eventually become unavailable */ - public function apiAppGetWithHttpInfo(string $client_id) + public function apiAppGetWithHttpInfo(string $client_id, string $contentType = self::contentTypes['apiAppGet'][0]) { - $request = $this->apiAppGetRequest($client_id); + $request = $this->apiAppGetRequest($client_id, $contentType); try { $options = $this->createHttpClientOption(); @@ -738,14 +767,14 @@ public function apiAppGetWithHttpInfo(string $client_id) } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -758,51 +787,73 @@ public function apiAppGetWithHttpInfo(string $client_id) sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\ApiAppGetResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ApiAppGetResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\ApiAppGetResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\ApiAppGetResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ApiAppGetResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\ApiAppGetResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -811,28 +862,19 @@ public function apiAppGetWithHttpInfo(string $client_id) $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ApiAppGetResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\ApiAppGetResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -842,14 +884,16 @@ public function apiAppGetWithHttpInfo(string $client_id) * * Get API App * - * @param string $client_id The client id of the API App to retrieve. (required) + * @param string $client_id The client id of the API App to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiAppGet'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::apiAppGet. This method will eventually become unavailable */ - public function apiAppGetAsync(string $client_id) + public function apiAppGetAsync(string $client_id, string $contentType = self::contentTypes['apiAppGet'][0]) { - return $this->apiAppGetAsyncWithHttpInfo($client_id) + return $this->apiAppGetAsyncWithHttpInfo($client_id, $contentType) ->then( function ($response) { return $response[0]; @@ -862,24 +906,29 @@ function ($response) { * * Get API App * - * @param string $client_id The client id of the API App to retrieve. (required) + * @param string $client_id The client id of the API App to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiAppGet'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::apiAppGet. This method will eventually become unavailable */ - public function apiAppGetAsyncWithHttpInfo(string $client_id) + public function apiAppGetAsyncWithHttpInfo(string $client_id, string $contentType = self::contentTypes['apiAppGet'][0]) { $returnType = '\Dropbox\Sign\Model\ApiAppGetResponse'; - $request = $this->apiAppGetRequest($client_id); + $request = $this->apiAppGetRequest($client_id, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -899,7 +948,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -908,12 +957,14 @@ function ($exception) { /** * Create request for operation 'apiAppGet' * - * @param string $client_id The client id of the API App to retrieve. (required) + * @param string $client_id The client id of the API App to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiAppGet'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::apiAppGet. This method will eventually become unavailable */ - public function apiAppGetRequest(string $client_id) + public function apiAppGetRequest(string $client_id, string $contentType = self::contentTypes['apiAppGet'][0]) { // verify the required parameter 'client_id' is set if ($client_id === null || (is_array($client_id) && count($client_id) === 0)) { @@ -923,32 +974,26 @@ public function apiAppGetRequest(string $client_id) } $resourcePath = '/api_app/{client_id}'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // path params if ($client_id !== null) { $resourcePath = str_replace( - '{' . 'client_id' . '}', + '{client_id}', ObjectSerializer::toPathValue($client_id), $resourcePath ); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -966,18 +1011,19 @@ public function apiAppGetRequest(string $client_id) // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -1001,11 +1047,11 @@ public function apiAppGetRequest(string $client_id) $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'GET', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1016,17 +1062,16 @@ public function apiAppGetRequest(string $client_id) * * List API Apps * - * @param int $page Which page number of the API App List to return. Defaults to `1`. (optional, default to 1) + * @param int $page Which page number of the API App List to return. Defaults to `1`. (optional, default to 1) * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\ApiAppListResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function apiAppList(int $page = 1, int $page_size = 20) { list($response) = $this->apiAppListWithHttpInfo($page, $page_size); - return $response; } @@ -1035,16 +1080,18 @@ public function apiAppList(int $page = 1, int $page_size = 20) * * List API Apps * - * @param int $page Which page number of the API App List to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param int $page Which page number of the API App List to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiAppList'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\ApiAppListResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::apiAppList. This method will eventually become unavailable */ - public function apiAppListWithHttpInfo(int $page = 1, int $page_size = 20) + public function apiAppListWithHttpInfo(int $page = 1, int $page_size = 20, string $contentType = self::contentTypes['apiAppList'][0]) { - $request = $this->apiAppListRequest($page, $page_size); + $request = $this->apiAppListRequest($page, $page_size, $contentType); try { $options = $this->createHttpClientOption(); @@ -1054,14 +1101,14 @@ public function apiAppListWithHttpInfo(int $page = 1, int $page_size = 20) } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -1074,51 +1121,73 @@ public function apiAppListWithHttpInfo(int $page = 1, int $page_size = 20) sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\ApiAppListResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ApiAppListResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\ApiAppListResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\ApiAppListResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ApiAppListResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\ApiAppListResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -1127,28 +1196,19 @@ public function apiAppListWithHttpInfo(int $page = 1, int $page_size = 20) $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ApiAppListResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\ApiAppListResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -1158,15 +1218,17 @@ public function apiAppListWithHttpInfo(int $page = 1, int $page_size = 20) * * List API Apps * - * @param int $page Which page number of the API App List to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param int $page Which page number of the API App List to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiAppList'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::apiAppList. This method will eventually become unavailable */ - public function apiAppListAsync(int $page = 1, int $page_size = 20) + public function apiAppListAsync(int $page = 1, int $page_size = 20, string $contentType = self::contentTypes['apiAppList'][0]) { - return $this->apiAppListAsyncWithHttpInfo($page, $page_size) + return $this->apiAppListAsyncWithHttpInfo($page, $page_size, $contentType) ->then( function ($response) { return $response[0]; @@ -1179,25 +1241,30 @@ function ($response) { * * List API Apps * - * @param int $page Which page number of the API App List to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param int $page Which page number of the API App List to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiAppList'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::apiAppList. This method will eventually become unavailable */ - public function apiAppListAsyncWithHttpInfo(int $page = 1, int $page_size = 20) + public function apiAppListAsyncWithHttpInfo(int $page = 1, int $page_size = 20, string $contentType = self::contentTypes['apiAppList'][0]) { $returnType = '\Dropbox\Sign\Model\ApiAppListResponse'; - $request = $this->apiAppListRequest($page, $page_size); + $request = $this->apiAppListRequest($page, $page_size, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -1217,7 +1284,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -1226,53 +1293,47 @@ function ($exception) { /** * Create request for operation 'apiAppList' * - * @param int $page Which page number of the API App List to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param int $page Which page number of the API App List to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiAppList'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::apiAppList. This method will eventually become unavailable */ - public function apiAppListRequest(int $page = 1, int $page_size = 20) + public function apiAppListRequest(int $page = 1, int $page_size = 20, string $contentType = self::contentTypes['apiAppList'][0]) { $resourcePath = '/api_app/list'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // query params - if ($page !== null) { - if ('form' === 'form' && is_array($page)) { - foreach ($page as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['page'] = $page; - } - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); // query params - if ($page_size !== null) { - if ('form' === 'form' && is_array($page_size)) { - foreach ($page_size as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['page_size'] = $page_size; - } - } - - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'page_size', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -1290,18 +1351,19 @@ public function apiAppListRequest(int $page = 1, int $page_size = 20) // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -1325,11 +1387,11 @@ public function apiAppListRequest(int $page = 1, int $page_size = 20) $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'GET', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1340,17 +1402,16 @@ public function apiAppListRequest(int $page = 1, int $page_size = 20) * * Update API App * - * @param string $client_id The client id of the API App to update. (required) + * @param string $client_id The client id of the API App to update. (required) * @param Model\ApiAppUpdateRequest $api_app_update_request api_app_update_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\ApiAppGetResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function apiAppUpdate(string $client_id, Model\ApiAppUpdateRequest $api_app_update_request) { list($response) = $this->apiAppUpdateWithHttpInfo($client_id, $api_app_update_request); - return $response; } @@ -1359,16 +1420,18 @@ public function apiAppUpdate(string $client_id, Model\ApiAppUpdateRequest $api_a * * Update API App * - * @param string $client_id The client id of the API App to update. (required) + * @param string $client_id The client id of the API App to update. (required) * @param Model\ApiAppUpdateRequest $api_app_update_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiAppUpdate'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\ApiAppGetResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::apiAppUpdate. This method will eventually become unavailable */ - public function apiAppUpdateWithHttpInfo(string $client_id, Model\ApiAppUpdateRequest $api_app_update_request) + public function apiAppUpdateWithHttpInfo(string $client_id, Model\ApiAppUpdateRequest $api_app_update_request, string $contentType = self::contentTypes['apiAppUpdate'][0]) { - $request = $this->apiAppUpdateRequest($client_id, $api_app_update_request); + $request = $this->apiAppUpdateRequest($client_id, $api_app_update_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -1378,14 +1441,14 @@ public function apiAppUpdateWithHttpInfo(string $client_id, Model\ApiAppUpdateRe } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -1398,51 +1461,73 @@ public function apiAppUpdateWithHttpInfo(string $client_id, Model\ApiAppUpdateRe sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\ApiAppGetResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ApiAppGetResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\ApiAppGetResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\ApiAppGetResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ApiAppGetResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\ApiAppGetResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -1451,28 +1536,19 @@ public function apiAppUpdateWithHttpInfo(string $client_id, Model\ApiAppUpdateRe $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ApiAppGetResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\ApiAppGetResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -1482,15 +1558,17 @@ public function apiAppUpdateWithHttpInfo(string $client_id, Model\ApiAppUpdateRe * * Update API App * - * @param string $client_id The client id of the API App to update. (required) + * @param string $client_id The client id of the API App to update. (required) * @param Model\ApiAppUpdateRequest $api_app_update_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiAppUpdate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::apiAppUpdate. This method will eventually become unavailable */ - public function apiAppUpdateAsync(string $client_id, Model\ApiAppUpdateRequest $api_app_update_request) + public function apiAppUpdateAsync(string $client_id, Model\ApiAppUpdateRequest $api_app_update_request, string $contentType = self::contentTypes['apiAppUpdate'][0]) { - return $this->apiAppUpdateAsyncWithHttpInfo($client_id, $api_app_update_request) + return $this->apiAppUpdateAsyncWithHttpInfo($client_id, $api_app_update_request, $contentType) ->then( function ($response) { return $response[0]; @@ -1503,25 +1581,30 @@ function ($response) { * * Update API App * - * @param string $client_id The client id of the API App to update. (required) + * @param string $client_id The client id of the API App to update. (required) * @param Model\ApiAppUpdateRequest $api_app_update_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiAppUpdate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::apiAppUpdate. This method will eventually become unavailable */ - public function apiAppUpdateAsyncWithHttpInfo(string $client_id, Model\ApiAppUpdateRequest $api_app_update_request) + public function apiAppUpdateAsyncWithHttpInfo(string $client_id, Model\ApiAppUpdateRequest $api_app_update_request, string $contentType = self::contentTypes['apiAppUpdate'][0]) { $returnType = '\Dropbox\Sign\Model\ApiAppGetResponse'; - $request = $this->apiAppUpdateRequest($client_id, $api_app_update_request); + $request = $this->apiAppUpdateRequest($client_id, $api_app_update_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -1541,7 +1624,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -1550,13 +1633,15 @@ function ($exception) { /** * Create request for operation 'apiAppUpdate' * - * @param string $client_id The client id of the API App to update. (required) + * @param string $client_id The client id of the API App to update. (required) * @param Model\ApiAppUpdateRequest $api_app_update_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiAppUpdate'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::apiAppUpdate. This method will eventually become unavailable */ - public function apiAppUpdateRequest(string $client_id, Model\ApiAppUpdateRequest $api_app_update_request) + public function apiAppUpdateRequest(string $client_id, Model\ApiAppUpdateRequest $api_app_update_request, string $contentType = self::contentTypes['apiAppUpdate'][0]) { // verify the required parameter 'client_id' is set if ($client_id === null || (is_array($client_id) && count($client_id) === 0)) { @@ -1564,6 +1649,7 @@ public function apiAppUpdateRequest(string $client_id, Model\ApiAppUpdateRequest 'Missing the required parameter $client_id when calling apiAppUpdate' ); } + // verify the required parameter 'api_app_update_request' is set if ($api_app_update_request === null || (is_array($api_app_update_request) && count($api_app_update_request) === 0)) { throw new InvalidArgumentException( @@ -1572,9 +1658,11 @@ public function apiAppUpdateRequest(string $client_id, Model\ApiAppUpdateRequest } $resourcePath = '/api_app/{client_id}'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $api_app_update_request @@ -1585,27 +1673,23 @@ public function apiAppUpdateRequest(string $client_id, Model\ApiAppUpdateRequest // path params if ($client_id !== null) { $resourcePath = str_replace( - '{' . 'client_id' . '}', + '{client_id}', ObjectSerializer::toPathValue($client_id), $resourcePath ); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json', 'multipart/form-data'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($api_app_update_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($api_app_update_request)); } else { $httpBody = $api_app_update_request; } @@ -1624,22 +1708,22 @@ public function apiAppUpdateRequest(string $client_id, Model\ApiAppUpdateRequest // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $api_app_update_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -1663,11 +1747,11 @@ public function apiAppUpdateRequest(string $client_id, Model\ApiAppUpdateRequest $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'PUT', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1676,8 +1760,8 @@ public function apiAppUpdateRequest(string $client_id, Model\ApiAppUpdateRequest /** * Create http client option * - * @throws RuntimeException on file opening failure * @return array of http client options + * @throws RuntimeException on file opening failure */ protected function createHttpClientOption() { @@ -1691,4 +1775,66 @@ protected function createHttpClientOption() return $options; } + + /** + * @return object|array|null + */ + private function handleRangeCodeResponse( + ResponseInterface $response, + string $rangeCode, + string $returnDataType + ) { + $statusCode = $response->getStatusCode(); + $rangeCodeLeft = (int)(substr($rangeCode, 0, 1) . '00'); + $rangeCodeRight = (int)(substr($rangeCode, 0, 1) . '99'); + + if ( + $statusCode < $rangeCodeLeft + || $statusCode > $rangeCodeRight + ) { + return null; + } + + if ($returnDataType === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + } + + return [ + ObjectSerializer::deserialize($content, $returnDataType, []), + $statusCode, + $response->getHeaders(), + ]; + } + + /** + * @return object|array|null + */ + private function handleRangeCodeException( + ApiException $e, + string $rangeCode, + string $exceptionDataType + ): bool { + $statusCode = $e->getCode(); + $rangeCodeLeft = (int)(substr($rangeCode, 0, 1) . '00'); + $rangeCodeRight = (int)(substr($rangeCode, 0, 1) . '99'); + + if ( + $statusCode < $rangeCodeLeft + || $statusCode > $rangeCodeRight + ) { + return false; + } + + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + $exceptionDataType, + $e->getResponseHeaders() + ); + + $e->setResponseObject($data); + + return true; + } } diff --git a/sdks/php/src/Api/BulkSendJobApi.php b/sdks/php/src/Api/BulkSendJobApi.php index 3656b9587..77ad055c7 100644 --- a/sdks/php/src/Api/BulkSendJobApi.php +++ b/sdks/php/src/Api/BulkSendJobApi.php @@ -4,7 +4,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -16,7 +15,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -36,11 +35,11 @@ use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Promise; -use GuzzleHttp\Psr7; +use GuzzleHttp\Psr7\MultipartStream; +use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; -use GuzzleHttp\Utils; use InvalidArgumentException; +use JsonException; use Psr\Http\Message\ResponseInterface; use RuntimeException; @@ -48,34 +47,35 @@ * BulkSendJobApi Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ class BulkSendJobApi { - /** - * @var ClientInterface - */ + /** @var ClientInterface */ protected $client; - /** - * @var Configuration - */ + /** @var Configuration */ protected $config; - /** - * @var HeaderSelector - */ + /** @var HeaderSelector */ protected $headerSelector; - /** - * @var int Host index - */ + /** @var int Host index */ protected $hostIndex; /** - * @var ResponseInterface|null + * @var string[] * */ + public const contentTypes = [ + 'bulkSendJobGet' => [ + 'application/json', + ], + 'bulkSendJobList' => [ + 'application/json', + ], + ]; + + /** @var ResponseInterface|null */ protected $response; /** @@ -97,6 +97,7 @@ public function __construct( * Set the host index * * @param int $hostIndex Host index (required) + * @deprecated To be made private in the future */ public function setHostIndex(int $hostIndex): void { @@ -107,6 +108,7 @@ public function setHostIndex(int $hostIndex): void * Get the host index * * @return int Host index + * @deprecated To be made private in the future */ public function getHostIndex() { @@ -135,17 +137,16 @@ public function getResponse() * Get Bulk Send Job * * @param string $bulk_send_job_id The id of the BulkSendJob to retrieve. (required) - * @param int $page Which page number of the BulkSendJob list to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is 20. (optional, default to 20) + * @param int $page Which page number of the BulkSendJob list to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is 20. (optional, default to 20) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\BulkSendJobGetResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function bulkSendJobGet(string $bulk_send_job_id, int $page = 1, int $page_size = 20) { list($response) = $this->bulkSendJobGetWithHttpInfo($bulk_send_job_id, $page, $page_size); - return $response; } @@ -155,16 +156,18 @@ public function bulkSendJobGet(string $bulk_send_job_id, int $page = 1, int $pag * Get Bulk Send Job * * @param string $bulk_send_job_id The id of the BulkSendJob to retrieve. (required) - * @param int $page Which page number of the BulkSendJob list to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is 20. (optional, default to 20) + * @param int $page Which page number of the BulkSendJob list to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is 20. (optional, default to 20) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['bulkSendJobGet'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\BulkSendJobGetResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::bulkSendJobGet. This method will eventually become unavailable */ - public function bulkSendJobGetWithHttpInfo(string $bulk_send_job_id, int $page = 1, int $page_size = 20) + public function bulkSendJobGetWithHttpInfo(string $bulk_send_job_id, int $page = 1, int $page_size = 20, string $contentType = self::contentTypes['bulkSendJobGet'][0]) { - $request = $this->bulkSendJobGetRequest($bulk_send_job_id, $page, $page_size); + $request = $this->bulkSendJobGetRequest($bulk_send_job_id, $page, $page_size, $contentType); try { $options = $this->createHttpClientOption(); @@ -174,14 +177,14 @@ public function bulkSendJobGetWithHttpInfo(string $bulk_send_job_id, int $page = } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -194,51 +197,73 @@ public function bulkSendJobGetWithHttpInfo(string $bulk_send_job_id, int $page = sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\BulkSendJobGetResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\BulkSendJobGetResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\BulkSendJobGetResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\BulkSendJobGetResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\BulkSendJobGetResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\BulkSendJobGetResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -247,28 +272,19 @@ public function bulkSendJobGetWithHttpInfo(string $bulk_send_job_id, int $page = $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\BulkSendJobGetResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\BulkSendJobGetResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -279,15 +295,17 @@ public function bulkSendJobGetWithHttpInfo(string $bulk_send_job_id, int $page = * Get Bulk Send Job * * @param string $bulk_send_job_id The id of the BulkSendJob to retrieve. (required) - * @param int $page Which page number of the BulkSendJob list to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is 20. (optional, default to 20) + * @param int $page Which page number of the BulkSendJob list to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is 20. (optional, default to 20) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['bulkSendJobGet'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::bulkSendJobGet. This method will eventually become unavailable */ - public function bulkSendJobGetAsync(string $bulk_send_job_id, int $page = 1, int $page_size = 20) + public function bulkSendJobGetAsync(string $bulk_send_job_id, int $page = 1, int $page_size = 20, string $contentType = self::contentTypes['bulkSendJobGet'][0]) { - return $this->bulkSendJobGetAsyncWithHttpInfo($bulk_send_job_id, $page, $page_size) + return $this->bulkSendJobGetAsyncWithHttpInfo($bulk_send_job_id, $page, $page_size, $contentType) ->then( function ($response) { return $response[0]; @@ -301,25 +319,30 @@ function ($response) { * Get Bulk Send Job * * @param string $bulk_send_job_id The id of the BulkSendJob to retrieve. (required) - * @param int $page Which page number of the BulkSendJob list to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is 20. (optional, default to 20) + * @param int $page Which page number of the BulkSendJob list to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is 20. (optional, default to 20) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['bulkSendJobGet'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::bulkSendJobGet. This method will eventually become unavailable */ - public function bulkSendJobGetAsyncWithHttpInfo(string $bulk_send_job_id, int $page = 1, int $page_size = 20) + public function bulkSendJobGetAsyncWithHttpInfo(string $bulk_send_job_id, int $page = 1, int $page_size = 20, string $contentType = self::contentTypes['bulkSendJobGet'][0]) { $returnType = '\Dropbox\Sign\Model\BulkSendJobGetResponse'; - $request = $this->bulkSendJobGetRequest($bulk_send_job_id, $page, $page_size); + $request = $this->bulkSendJobGetRequest($bulk_send_job_id, $page, $page_size, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -339,7 +362,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -349,13 +372,15 @@ function ($exception) { * Create request for operation 'bulkSendJobGet' * * @param string $bulk_send_job_id The id of the BulkSendJob to retrieve. (required) - * @param int $page Which page number of the BulkSendJob list to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is 20. (optional, default to 20) + * @param int $page Which page number of the BulkSendJob list to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is 20. (optional, default to 20) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['bulkSendJobGet'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::bulkSendJobGet. This method will eventually become unavailable */ - public function bulkSendJobGetRequest(string $bulk_send_job_id, int $page = 1, int $page_size = 20) + public function bulkSendJobGetRequest(string $bulk_send_job_id, int $page = 1, int $page_size = 20, string $contentType = self::contentTypes['bulkSendJobGet'][0]) { // verify the required parameter 'bulk_send_job_id' is set if ($bulk_send_job_id === null || (is_array($bulk_send_job_id) && count($bulk_send_job_id) === 0)) { @@ -365,53 +390,45 @@ public function bulkSendJobGetRequest(string $bulk_send_job_id, int $page = 1, i } $resourcePath = '/bulk_send_job/{bulk_send_job_id}'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // query params - if ($page !== null) { - if ('form' === 'form' && is_array($page)) { - foreach ($page as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['page'] = $page; - } - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); // query params - if ($page_size !== null) { - if ('form' === 'form' && is_array($page_size)) { - foreach ($page_size as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['page_size'] = $page_size; - } - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'page_size', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); // path params if ($bulk_send_job_id !== null) { $resourcePath = str_replace( - '{' . 'bulk_send_job_id' . '}', + '{bulk_send_job_id}', ObjectSerializer::toPathValue($bulk_send_job_id), $resourcePath ); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -429,18 +446,19 @@ public function bulkSendJobGetRequest(string $bulk_send_job_id, int $page = 1, i // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -464,11 +482,11 @@ public function bulkSendJobGetRequest(string $bulk_send_job_id, int $page = 1, i $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'GET', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -479,17 +497,16 @@ public function bulkSendJobGetRequest(string $bulk_send_job_id, int $page = 1, i * * List Bulk Send Jobs * - * @param int $page Which page number of the BulkSendJob List to return. Defaults to `1`. (optional, default to 1) + * @param int $page Which page number of the BulkSendJob List to return. Defaults to `1`. (optional, default to 1) * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is 20. (optional, default to 20) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\BulkSendJobListResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function bulkSendJobList(int $page = 1, int $page_size = 20) { list($response) = $this->bulkSendJobListWithHttpInfo($page, $page_size); - return $response; } @@ -498,16 +515,18 @@ public function bulkSendJobList(int $page = 1, int $page_size = 20) * * List Bulk Send Jobs * - * @param int $page Which page number of the BulkSendJob List to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is 20. (optional, default to 20) + * @param int $page Which page number of the BulkSendJob List to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is 20. (optional, default to 20) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['bulkSendJobList'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\BulkSendJobListResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::bulkSendJobList. This method will eventually become unavailable */ - public function bulkSendJobListWithHttpInfo(int $page = 1, int $page_size = 20) + public function bulkSendJobListWithHttpInfo(int $page = 1, int $page_size = 20, string $contentType = self::contentTypes['bulkSendJobList'][0]) { - $request = $this->bulkSendJobListRequest($page, $page_size); + $request = $this->bulkSendJobListRequest($page, $page_size, $contentType); try { $options = $this->createHttpClientOption(); @@ -517,14 +536,14 @@ public function bulkSendJobListWithHttpInfo(int $page = 1, int $page_size = 20) } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -537,51 +556,73 @@ public function bulkSendJobListWithHttpInfo(int $page = 1, int $page_size = 20) sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\BulkSendJobListResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\BulkSendJobListResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\BulkSendJobListResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\BulkSendJobListResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\BulkSendJobListResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\BulkSendJobListResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -590,28 +631,19 @@ public function bulkSendJobListWithHttpInfo(int $page = 1, int $page_size = 20) $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\BulkSendJobListResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\BulkSendJobListResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -621,15 +653,17 @@ public function bulkSendJobListWithHttpInfo(int $page = 1, int $page_size = 20) * * List Bulk Send Jobs * - * @param int $page Which page number of the BulkSendJob List to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is 20. (optional, default to 20) + * @param int $page Which page number of the BulkSendJob List to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is 20. (optional, default to 20) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['bulkSendJobList'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::bulkSendJobList. This method will eventually become unavailable */ - public function bulkSendJobListAsync(int $page = 1, int $page_size = 20) + public function bulkSendJobListAsync(int $page = 1, int $page_size = 20, string $contentType = self::contentTypes['bulkSendJobList'][0]) { - return $this->bulkSendJobListAsyncWithHttpInfo($page, $page_size) + return $this->bulkSendJobListAsyncWithHttpInfo($page, $page_size, $contentType) ->then( function ($response) { return $response[0]; @@ -642,25 +676,30 @@ function ($response) { * * List Bulk Send Jobs * - * @param int $page Which page number of the BulkSendJob List to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is 20. (optional, default to 20) + * @param int $page Which page number of the BulkSendJob List to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is 20. (optional, default to 20) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['bulkSendJobList'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::bulkSendJobList. This method will eventually become unavailable */ - public function bulkSendJobListAsyncWithHttpInfo(int $page = 1, int $page_size = 20) + public function bulkSendJobListAsyncWithHttpInfo(int $page = 1, int $page_size = 20, string $contentType = self::contentTypes['bulkSendJobList'][0]) { $returnType = '\Dropbox\Sign\Model\BulkSendJobListResponse'; - $request = $this->bulkSendJobListRequest($page, $page_size); + $request = $this->bulkSendJobListRequest($page, $page_size, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -680,7 +719,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -689,53 +728,47 @@ function ($exception) { /** * Create request for operation 'bulkSendJobList' * - * @param int $page Which page number of the BulkSendJob List to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is 20. (optional, default to 20) + * @param int $page Which page number of the BulkSendJob List to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is 20. (optional, default to 20) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['bulkSendJobList'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::bulkSendJobList. This method will eventually become unavailable */ - public function bulkSendJobListRequest(int $page = 1, int $page_size = 20) + public function bulkSendJobListRequest(int $page = 1, int $page_size = 20, string $contentType = self::contentTypes['bulkSendJobList'][0]) { $resourcePath = '/bulk_send_job/list'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // query params - if ($page !== null) { - if ('form' === 'form' && is_array($page)) { - foreach ($page as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['page'] = $page; - } - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); // query params - if ($page_size !== null) { - if ('form' === 'form' && is_array($page_size)) { - foreach ($page_size as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['page_size'] = $page_size; - } - } - - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'page_size', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -753,18 +786,19 @@ public function bulkSendJobListRequest(int $page = 1, int $page_size = 20) // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -788,11 +822,11 @@ public function bulkSendJobListRequest(int $page = 1, int $page_size = 20) $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'GET', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -801,8 +835,8 @@ public function bulkSendJobListRequest(int $page = 1, int $page_size = 20) /** * Create http client option * - * @throws RuntimeException on file opening failure * @return array of http client options + * @throws RuntimeException on file opening failure */ protected function createHttpClientOption() { @@ -816,4 +850,66 @@ protected function createHttpClientOption() return $options; } + + /** + * @return object|array|null + */ + private function handleRangeCodeResponse( + ResponseInterface $response, + string $rangeCode, + string $returnDataType + ) { + $statusCode = $response->getStatusCode(); + $rangeCodeLeft = (int)(substr($rangeCode, 0, 1) . '00'); + $rangeCodeRight = (int)(substr($rangeCode, 0, 1) . '99'); + + if ( + $statusCode < $rangeCodeLeft + || $statusCode > $rangeCodeRight + ) { + return null; + } + + if ($returnDataType === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + } + + return [ + ObjectSerializer::deserialize($content, $returnDataType, []), + $statusCode, + $response->getHeaders(), + ]; + } + + /** + * @return object|array|null + */ + private function handleRangeCodeException( + ApiException $e, + string $rangeCode, + string $exceptionDataType + ): bool { + $statusCode = $e->getCode(); + $rangeCodeLeft = (int)(substr($rangeCode, 0, 1) . '00'); + $rangeCodeRight = (int)(substr($rangeCode, 0, 1) . '99'); + + if ( + $statusCode < $rangeCodeLeft + || $statusCode > $rangeCodeRight + ) { + return false; + } + + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + $exceptionDataType, + $e->getResponseHeaders() + ); + + $e->setResponseObject($data); + + return true; + } } diff --git a/sdks/php/src/Api/EmbeddedApi.php b/sdks/php/src/Api/EmbeddedApi.php index 727145692..364e5f7e7 100644 --- a/sdks/php/src/Api/EmbeddedApi.php +++ b/sdks/php/src/Api/EmbeddedApi.php @@ -4,7 +4,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -16,7 +15,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -36,11 +35,11 @@ use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Promise; -use GuzzleHttp\Psr7; +use GuzzleHttp\Psr7\MultipartStream; +use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; -use GuzzleHttp\Utils; use InvalidArgumentException; +use JsonException; use Psr\Http\Message\ResponseInterface; use RuntimeException; @@ -48,34 +47,35 @@ * EmbeddedApi Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ class EmbeddedApi { - /** - * @var ClientInterface - */ + /** @var ClientInterface */ protected $client; - /** - * @var Configuration - */ + /** @var Configuration */ protected $config; - /** - * @var HeaderSelector - */ + /** @var HeaderSelector */ protected $headerSelector; - /** - * @var int Host index - */ + /** @var int Host index */ protected $hostIndex; /** - * @var ResponseInterface|null + * @var string[] * */ + public const contentTypes = [ + 'embeddedEditUrl' => [ + 'application/json', + ], + 'embeddedSignUrl' => [ + 'application/json', + ], + ]; + + /** @var ResponseInterface|null */ protected $response; /** @@ -97,6 +97,7 @@ public function __construct( * Set the host index * * @param int $hostIndex Host index (required) + * @deprecated To be made private in the future */ public function setHostIndex(int $hostIndex): void { @@ -107,6 +108,7 @@ public function setHostIndex(int $hostIndex): void * Get the host index * * @return int Host index + * @deprecated To be made private in the future */ public function getHostIndex() { @@ -134,17 +136,16 @@ public function getResponse() * * Get Embedded Template Edit URL * - * @param string $template_id The id of the template to edit. (required) + * @param string $template_id The id of the template to edit. (required) * @param Model\EmbeddedEditUrlRequest $embedded_edit_url_request embedded_edit_url_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\EmbeddedEditUrlResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function embeddedEditUrl(string $template_id, Model\EmbeddedEditUrlRequest $embedded_edit_url_request) { list($response) = $this->embeddedEditUrlWithHttpInfo($template_id, $embedded_edit_url_request); - return $response; } @@ -153,16 +154,18 @@ public function embeddedEditUrl(string $template_id, Model\EmbeddedEditUrlReques * * Get Embedded Template Edit URL * - * @param string $template_id The id of the template to edit. (required) + * @param string $template_id The id of the template to edit. (required) * @param Model\EmbeddedEditUrlRequest $embedded_edit_url_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['embeddedEditUrl'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\EmbeddedEditUrlResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::embeddedEditUrl. This method will eventually become unavailable */ - public function embeddedEditUrlWithHttpInfo(string $template_id, Model\EmbeddedEditUrlRequest $embedded_edit_url_request) + public function embeddedEditUrlWithHttpInfo(string $template_id, Model\EmbeddedEditUrlRequest $embedded_edit_url_request, string $contentType = self::contentTypes['embeddedEditUrl'][0]) { - $request = $this->embeddedEditUrlRequest($template_id, $embedded_edit_url_request); + $request = $this->embeddedEditUrlRequest($template_id, $embedded_edit_url_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -172,14 +175,14 @@ public function embeddedEditUrlWithHttpInfo(string $template_id, Model\EmbeddedE } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -192,51 +195,73 @@ public function embeddedEditUrlWithHttpInfo(string $template_id, Model\EmbeddedE sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\EmbeddedEditUrlResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\EmbeddedEditUrlResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\EmbeddedEditUrlResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\EmbeddedEditUrlResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\EmbeddedEditUrlResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\EmbeddedEditUrlResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -245,28 +270,19 @@ public function embeddedEditUrlWithHttpInfo(string $template_id, Model\EmbeddedE $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\EmbeddedEditUrlResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\EmbeddedEditUrlResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -276,15 +292,17 @@ public function embeddedEditUrlWithHttpInfo(string $template_id, Model\EmbeddedE * * Get Embedded Template Edit URL * - * @param string $template_id The id of the template to edit. (required) + * @param string $template_id The id of the template to edit. (required) * @param Model\EmbeddedEditUrlRequest $embedded_edit_url_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['embeddedEditUrl'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::embeddedEditUrl. This method will eventually become unavailable */ - public function embeddedEditUrlAsync(string $template_id, Model\EmbeddedEditUrlRequest $embedded_edit_url_request) + public function embeddedEditUrlAsync(string $template_id, Model\EmbeddedEditUrlRequest $embedded_edit_url_request, string $contentType = self::contentTypes['embeddedEditUrl'][0]) { - return $this->embeddedEditUrlAsyncWithHttpInfo($template_id, $embedded_edit_url_request) + return $this->embeddedEditUrlAsyncWithHttpInfo($template_id, $embedded_edit_url_request, $contentType) ->then( function ($response) { return $response[0]; @@ -297,25 +315,30 @@ function ($response) { * * Get Embedded Template Edit URL * - * @param string $template_id The id of the template to edit. (required) + * @param string $template_id The id of the template to edit. (required) * @param Model\EmbeddedEditUrlRequest $embedded_edit_url_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['embeddedEditUrl'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::embeddedEditUrl. This method will eventually become unavailable */ - public function embeddedEditUrlAsyncWithHttpInfo(string $template_id, Model\EmbeddedEditUrlRequest $embedded_edit_url_request) + public function embeddedEditUrlAsyncWithHttpInfo(string $template_id, Model\EmbeddedEditUrlRequest $embedded_edit_url_request, string $contentType = self::contentTypes['embeddedEditUrl'][0]) { $returnType = '\Dropbox\Sign\Model\EmbeddedEditUrlResponse'; - $request = $this->embeddedEditUrlRequest($template_id, $embedded_edit_url_request); + $request = $this->embeddedEditUrlRequest($template_id, $embedded_edit_url_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -335,7 +358,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -344,13 +367,15 @@ function ($exception) { /** * Create request for operation 'embeddedEditUrl' * - * @param string $template_id The id of the template to edit. (required) + * @param string $template_id The id of the template to edit. (required) * @param Model\EmbeddedEditUrlRequest $embedded_edit_url_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['embeddedEditUrl'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::embeddedEditUrl. This method will eventually become unavailable */ - public function embeddedEditUrlRequest(string $template_id, Model\EmbeddedEditUrlRequest $embedded_edit_url_request) + public function embeddedEditUrlRequest(string $template_id, Model\EmbeddedEditUrlRequest $embedded_edit_url_request, string $contentType = self::contentTypes['embeddedEditUrl'][0]) { // verify the required parameter 'template_id' is set if ($template_id === null || (is_array($template_id) && count($template_id) === 0)) { @@ -358,6 +383,7 @@ public function embeddedEditUrlRequest(string $template_id, Model\EmbeddedEditUr 'Missing the required parameter $template_id when calling embeddedEditUrl' ); } + // verify the required parameter 'embedded_edit_url_request' is set if ($embedded_edit_url_request === null || (is_array($embedded_edit_url_request) && count($embedded_edit_url_request) === 0)) { throw new InvalidArgumentException( @@ -366,9 +392,11 @@ public function embeddedEditUrlRequest(string $template_id, Model\EmbeddedEditUr } $resourcePath = '/embedded/edit_url/{template_id}'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $embedded_edit_url_request @@ -379,27 +407,23 @@ public function embeddedEditUrlRequest(string $template_id, Model\EmbeddedEditUr // path params if ($template_id !== null) { $resourcePath = str_replace( - '{' . 'template_id' . '}', + '{template_id}', ObjectSerializer::toPathValue($template_id), $resourcePath ); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($embedded_edit_url_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($embedded_edit_url_request)); } else { $httpBody = $embedded_edit_url_request; } @@ -418,22 +442,22 @@ public function embeddedEditUrlRequest(string $template_id, Model\EmbeddedEditUr // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $embedded_edit_url_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -457,11 +481,11 @@ public function embeddedEditUrlRequest(string $template_id, Model\EmbeddedEditUr $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -474,14 +498,13 @@ public function embeddedEditUrlRequest(string $template_id, Model\EmbeddedEditUr * * @param string $signature_id The id of the signature to get a signature url for. (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\EmbeddedSignUrlResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function embeddedSignUrl(string $signature_id) { list($response) = $this->embeddedSignUrlWithHttpInfo($signature_id); - return $response; } @@ -491,14 +514,16 @@ public function embeddedSignUrl(string $signature_id) * Get Embedded Sign URL * * @param string $signature_id The id of the signature to get a signature url for. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['embeddedSignUrl'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\EmbeddedSignUrlResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::embeddedSignUrl. This method will eventually become unavailable */ - public function embeddedSignUrlWithHttpInfo(string $signature_id) + public function embeddedSignUrlWithHttpInfo(string $signature_id, string $contentType = self::contentTypes['embeddedSignUrl'][0]) { - $request = $this->embeddedSignUrlRequest($signature_id); + $request = $this->embeddedSignUrlRequest($signature_id, $contentType); try { $options = $this->createHttpClientOption(); @@ -508,14 +533,14 @@ public function embeddedSignUrlWithHttpInfo(string $signature_id) } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -528,51 +553,73 @@ public function embeddedSignUrlWithHttpInfo(string $signature_id) sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\EmbeddedSignUrlResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\EmbeddedSignUrlResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\EmbeddedSignUrlResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\EmbeddedSignUrlResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\EmbeddedSignUrlResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\EmbeddedSignUrlResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -581,28 +628,19 @@ public function embeddedSignUrlWithHttpInfo(string $signature_id) $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\EmbeddedSignUrlResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\EmbeddedSignUrlResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -613,13 +651,15 @@ public function embeddedSignUrlWithHttpInfo(string $signature_id) * Get Embedded Sign URL * * @param string $signature_id The id of the signature to get a signature url for. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['embeddedSignUrl'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::embeddedSignUrl. This method will eventually become unavailable */ - public function embeddedSignUrlAsync(string $signature_id) + public function embeddedSignUrlAsync(string $signature_id, string $contentType = self::contentTypes['embeddedSignUrl'][0]) { - return $this->embeddedSignUrlAsyncWithHttpInfo($signature_id) + return $this->embeddedSignUrlAsyncWithHttpInfo($signature_id, $contentType) ->then( function ($response) { return $response[0]; @@ -633,23 +673,28 @@ function ($response) { * Get Embedded Sign URL * * @param string $signature_id The id of the signature to get a signature url for. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['embeddedSignUrl'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::embeddedSignUrl. This method will eventually become unavailable */ - public function embeddedSignUrlAsyncWithHttpInfo(string $signature_id) + public function embeddedSignUrlAsyncWithHttpInfo(string $signature_id, string $contentType = self::contentTypes['embeddedSignUrl'][0]) { $returnType = '\Dropbox\Sign\Model\EmbeddedSignUrlResponse'; - $request = $this->embeddedSignUrlRequest($signature_id); + $request = $this->embeddedSignUrlRequest($signature_id, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -669,7 +714,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -679,11 +724,13 @@ function ($exception) { * Create request for operation 'embeddedSignUrl' * * @param string $signature_id The id of the signature to get a signature url for. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['embeddedSignUrl'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::embeddedSignUrl. This method will eventually become unavailable */ - public function embeddedSignUrlRequest(string $signature_id) + public function embeddedSignUrlRequest(string $signature_id, string $contentType = self::contentTypes['embeddedSignUrl'][0]) { // verify the required parameter 'signature_id' is set if ($signature_id === null || (is_array($signature_id) && count($signature_id) === 0)) { @@ -693,32 +740,26 @@ public function embeddedSignUrlRequest(string $signature_id) } $resourcePath = '/embedded/sign_url/{signature_id}'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // path params if ($signature_id !== null) { $resourcePath = str_replace( - '{' . 'signature_id' . '}', + '{signature_id}', ObjectSerializer::toPathValue($signature_id), $resourcePath ); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -736,18 +777,19 @@ public function embeddedSignUrlRequest(string $signature_id) // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -771,11 +813,11 @@ public function embeddedSignUrlRequest(string $signature_id) $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'GET', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -784,8 +826,8 @@ public function embeddedSignUrlRequest(string $signature_id) /** * Create http client option * - * @throws RuntimeException on file opening failure * @return array of http client options + * @throws RuntimeException on file opening failure */ protected function createHttpClientOption() { @@ -799,4 +841,66 @@ protected function createHttpClientOption() return $options; } + + /** + * @return object|array|null + */ + private function handleRangeCodeResponse( + ResponseInterface $response, + string $rangeCode, + string $returnDataType + ) { + $statusCode = $response->getStatusCode(); + $rangeCodeLeft = (int)(substr($rangeCode, 0, 1) . '00'); + $rangeCodeRight = (int)(substr($rangeCode, 0, 1) . '99'); + + if ( + $statusCode < $rangeCodeLeft + || $statusCode > $rangeCodeRight + ) { + return null; + } + + if ($returnDataType === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + } + + return [ + ObjectSerializer::deserialize($content, $returnDataType, []), + $statusCode, + $response->getHeaders(), + ]; + } + + /** + * @return object|array|null + */ + private function handleRangeCodeException( + ApiException $e, + string $rangeCode, + string $exceptionDataType + ): bool { + $statusCode = $e->getCode(); + $rangeCodeLeft = (int)(substr($rangeCode, 0, 1) . '00'); + $rangeCodeRight = (int)(substr($rangeCode, 0, 1) . '99'); + + if ( + $statusCode < $rangeCodeLeft + || $statusCode > $rangeCodeRight + ) { + return false; + } + + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + $exceptionDataType, + $e->getResponseHeaders() + ); + + $e->setResponseObject($data); + + return true; + } } diff --git a/sdks/php/src/Api/FaxLineApi.php b/sdks/php/src/Api/FaxLineApi.php index 11a334e0e..65cefff54 100644 --- a/sdks/php/src/Api/FaxLineApi.php +++ b/sdks/php/src/Api/FaxLineApi.php @@ -4,7 +4,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -16,7 +15,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -36,11 +35,11 @@ use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Promise; -use GuzzleHttp\Psr7; +use GuzzleHttp\Psr7\MultipartStream; +use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; -use GuzzleHttp\Utils; use InvalidArgumentException; +use JsonException; use Psr\Http\Message\ResponseInterface; use RuntimeException; @@ -48,34 +47,50 @@ * FaxLineApi Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ class FaxLineApi { - /** - * @var ClientInterface - */ + /** @var ClientInterface */ protected $client; - /** - * @var Configuration - */ + /** @var Configuration */ protected $config; - /** - * @var HeaderSelector - */ + /** @var HeaderSelector */ protected $headerSelector; - /** - * @var int Host index - */ + /** @var int Host index */ protected $hostIndex; /** - * @var ResponseInterface|null + * @var string[] * */ + public const contentTypes = [ + 'faxLineAddUser' => [ + 'application/json', + ], + 'faxLineAreaCodeGet' => [ + 'application/json', + ], + 'faxLineCreate' => [ + 'application/json', + ], + 'faxLineDelete' => [ + 'application/json', + ], + 'faxLineGet' => [ + 'application/json', + ], + 'faxLineList' => [ + 'application/json', + ], + 'faxLineRemoveUser' => [ + 'application/json', + ], + ]; + + /** @var ResponseInterface|null */ protected $response; /** @@ -97,6 +112,7 @@ public function __construct( * Set the host index * * @param int $hostIndex Host index (required) + * @deprecated To be made private in the future */ public function setHostIndex(int $hostIndex): void { @@ -107,6 +123,7 @@ public function setHostIndex(int $hostIndex): void * Get the host index * * @return int Host index + * @deprecated To be made private in the future */ public function getHostIndex() { @@ -136,14 +153,13 @@ public function getResponse() * * @param Model\FaxLineAddUserRequest $fax_line_add_user_request fax_line_add_user_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\FaxLineResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function faxLineAddUser(Model\FaxLineAddUserRequest $fax_line_add_user_request) { list($response) = $this->faxLineAddUserWithHttpInfo($fax_line_add_user_request); - return $response; } @@ -153,14 +169,16 @@ public function faxLineAddUser(Model\FaxLineAddUserRequest $fax_line_add_user_re * Add Fax Line User * * @param Model\FaxLineAddUserRequest $fax_line_add_user_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineAddUser'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\FaxLineResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::faxLineAddUser. This method will eventually become unavailable */ - public function faxLineAddUserWithHttpInfo(Model\FaxLineAddUserRequest $fax_line_add_user_request) + public function faxLineAddUserWithHttpInfo(Model\FaxLineAddUserRequest $fax_line_add_user_request, string $contentType = self::contentTypes['faxLineAddUser'][0]) { - $request = $this->faxLineAddUserRequest($fax_line_add_user_request); + $request = $this->faxLineAddUserRequest($fax_line_add_user_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -170,14 +188,14 @@ public function faxLineAddUserWithHttpInfo(Model\FaxLineAddUserRequest $fax_line } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -190,51 +208,73 @@ public function faxLineAddUserWithHttpInfo(Model\FaxLineAddUserRequest $fax_line sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\FaxLineResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\FaxLineResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\FaxLineResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\FaxLineResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\FaxLineResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\FaxLineResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -243,28 +283,19 @@ public function faxLineAddUserWithHttpInfo(Model\FaxLineAddUserRequest $fax_line $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\FaxLineResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\FaxLineResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -275,13 +306,15 @@ public function faxLineAddUserWithHttpInfo(Model\FaxLineAddUserRequest $fax_line * Add Fax Line User * * @param Model\FaxLineAddUserRequest $fax_line_add_user_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineAddUser'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::faxLineAddUser. This method will eventually become unavailable */ - public function faxLineAddUserAsync(Model\FaxLineAddUserRequest $fax_line_add_user_request) + public function faxLineAddUserAsync(Model\FaxLineAddUserRequest $fax_line_add_user_request, string $contentType = self::contentTypes['faxLineAddUser'][0]) { - return $this->faxLineAddUserAsyncWithHttpInfo($fax_line_add_user_request) + return $this->faxLineAddUserAsyncWithHttpInfo($fax_line_add_user_request, $contentType) ->then( function ($response) { return $response[0]; @@ -295,23 +328,28 @@ function ($response) { * Add Fax Line User * * @param Model\FaxLineAddUserRequest $fax_line_add_user_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineAddUser'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::faxLineAddUser. This method will eventually become unavailable */ - public function faxLineAddUserAsyncWithHttpInfo(Model\FaxLineAddUserRequest $fax_line_add_user_request) + public function faxLineAddUserAsyncWithHttpInfo(Model\FaxLineAddUserRequest $fax_line_add_user_request, string $contentType = self::contentTypes['faxLineAddUser'][0]) { $returnType = '\Dropbox\Sign\Model\FaxLineResponse'; - $request = $this->faxLineAddUserRequest($fax_line_add_user_request); + $request = $this->faxLineAddUserRequest($fax_line_add_user_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -331,7 +369,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -341,11 +379,13 @@ function ($exception) { * Create request for operation 'faxLineAddUser' * * @param Model\FaxLineAddUserRequest $fax_line_add_user_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineAddUser'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::faxLineAddUser. This method will eventually become unavailable */ - public function faxLineAddUserRequest(Model\FaxLineAddUserRequest $fax_line_add_user_request) + public function faxLineAddUserRequest(Model\FaxLineAddUserRequest $fax_line_add_user_request, string $contentType = self::contentTypes['faxLineAddUser'][0]) { // verify the required parameter 'fax_line_add_user_request' is set if ($fax_line_add_user_request === null || (is_array($fax_line_add_user_request) && count($fax_line_add_user_request) === 0)) { @@ -355,9 +395,11 @@ public function faxLineAddUserRequest(Model\FaxLineAddUserRequest $fax_line_add_ } $resourcePath = '/fax_line/add_user'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $fax_line_add_user_request @@ -365,21 +407,17 @@ public function faxLineAddUserRequest(Model\FaxLineAddUserRequest $fax_line_add_ $multipart = !empty($formParams); - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($fax_line_add_user_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($fax_line_add_user_request)); } else { $httpBody = $fax_line_add_user_request; } @@ -398,22 +436,22 @@ public function faxLineAddUserRequest(Model\FaxLineAddUserRequest $fax_line_add_ // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $fax_line_add_user_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -433,11 +471,11 @@ public function faxLineAddUserRequest(Model\FaxLineAddUserRequest $fax_line_add_ $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'PUT', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -448,19 +486,18 @@ public function faxLineAddUserRequest(Model\FaxLineAddUserRequest $fax_line_add_ * * Get Available Fax Line Area Codes * - * @param string $country Filter area codes by country. (required) - * @param string $state Filter area codes by state. (optional) + * @param string $country Filter area codes by country. (required) + * @param string $state Filter area codes by state. (optional) * @param string $province Filter area codes by province. (optional) - * @param string $city Filter area codes by city. (optional) + * @param string $city Filter area codes by city. (optional) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\FaxLineAreaCodeGetResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function faxLineAreaCodeGet(string $country, string $state = null, string $province = null, string $city = null) { list($response) = $this->faxLineAreaCodeGetWithHttpInfo($country, $state, $province, $city); - return $response; } @@ -469,18 +506,20 @@ public function faxLineAreaCodeGet(string $country, string $state = null, string * * Get Available Fax Line Area Codes * - * @param string $country Filter area codes by country. (required) - * @param string $state Filter area codes by state. (optional) - * @param string $province Filter area codes by province. (optional) - * @param string $city Filter area codes by city. (optional) + * @param string $country Filter area codes by country. (required) + * @param string $state Filter area codes by state. (optional) + * @param string $province Filter area codes by province. (optional) + * @param string $city Filter area codes by city. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineAreaCodeGet'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\FaxLineAreaCodeGetResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::faxLineAreaCodeGet. This method will eventually become unavailable */ - public function faxLineAreaCodeGetWithHttpInfo(string $country, string $state = null, string $province = null, string $city = null) + public function faxLineAreaCodeGetWithHttpInfo(string $country, string $state = null, string $province = null, string $city = null, string $contentType = self::contentTypes['faxLineAreaCodeGet'][0]) { - $request = $this->faxLineAreaCodeGetRequest($country, $state, $province, $city); + $request = $this->faxLineAreaCodeGetRequest($country, $state, $province, $city, $contentType); try { $options = $this->createHttpClientOption(); @@ -490,14 +529,14 @@ public function faxLineAreaCodeGetWithHttpInfo(string $country, string $state = } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -510,51 +549,73 @@ public function faxLineAreaCodeGetWithHttpInfo(string $country, string $state = sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\FaxLineAreaCodeGetResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\FaxLineAreaCodeGetResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\FaxLineAreaCodeGetResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\FaxLineAreaCodeGetResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\FaxLineAreaCodeGetResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\FaxLineAreaCodeGetResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -563,28 +624,19 @@ public function faxLineAreaCodeGetWithHttpInfo(string $country, string $state = $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\FaxLineAreaCodeGetResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\FaxLineAreaCodeGetResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -594,17 +646,19 @@ public function faxLineAreaCodeGetWithHttpInfo(string $country, string $state = * * Get Available Fax Line Area Codes * - * @param string $country Filter area codes by country. (required) - * @param string $state Filter area codes by state. (optional) - * @param string $province Filter area codes by province. (optional) - * @param string $city Filter area codes by city. (optional) + * @param string $country Filter area codes by country. (required) + * @param string $state Filter area codes by state. (optional) + * @param string $province Filter area codes by province. (optional) + * @param string $city Filter area codes by city. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineAreaCodeGet'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::faxLineAreaCodeGet. This method will eventually become unavailable */ - public function faxLineAreaCodeGetAsync(string $country, string $state = null, string $province = null, string $city = null) + public function faxLineAreaCodeGetAsync(string $country, string $state = null, string $province = null, string $city = null, string $contentType = self::contentTypes['faxLineAreaCodeGet'][0]) { - return $this->faxLineAreaCodeGetAsyncWithHttpInfo($country, $state, $province, $city) + return $this->faxLineAreaCodeGetAsyncWithHttpInfo($country, $state, $province, $city, $contentType) ->then( function ($response) { return $response[0]; @@ -617,27 +671,32 @@ function ($response) { * * Get Available Fax Line Area Codes * - * @param string $country Filter area codes by country. (required) - * @param string $state Filter area codes by state. (optional) - * @param string $province Filter area codes by province. (optional) - * @param string $city Filter area codes by city. (optional) + * @param string $country Filter area codes by country. (required) + * @param string $state Filter area codes by state. (optional) + * @param string $province Filter area codes by province. (optional) + * @param string $city Filter area codes by city. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineAreaCodeGet'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::faxLineAreaCodeGet. This method will eventually become unavailable */ - public function faxLineAreaCodeGetAsyncWithHttpInfo(string $country, string $state = null, string $province = null, string $city = null) + public function faxLineAreaCodeGetAsyncWithHttpInfo(string $country, string $state = null, string $province = null, string $city = null, string $contentType = self::contentTypes['faxLineAreaCodeGet'][0]) { $returnType = '\Dropbox\Sign\Model\FaxLineAreaCodeGetResponse'; - $request = $this->faxLineAreaCodeGetRequest($country, $state, $province, $city); + $request = $this->faxLineAreaCodeGetRequest($country, $state, $province, $city, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -657,7 +716,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -666,15 +725,17 @@ function ($exception) { /** * Create request for operation 'faxLineAreaCodeGet' * - * @param string $country Filter area codes by country. (required) - * @param string $state Filter area codes by state. (optional) - * @param string $province Filter area codes by province. (optional) - * @param string $city Filter area codes by city. (optional) + * @param string $country Filter area codes by country. (required) + * @param string $state Filter area codes by state. (optional) + * @param string $province Filter area codes by province. (optional) + * @param string $city Filter area codes by city. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineAreaCodeGet'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::faxLineAreaCodeGet. This method will eventually become unavailable */ - public function faxLineAreaCodeGetRequest(string $country, string $state = null, string $province = null, string $city = null) + public function faxLineAreaCodeGetRequest(string $country, string $state = null, string $province = null, string $city = null, string $contentType = self::contentTypes['faxLineAreaCodeGet'][0]) { // verify the required parameter 'country' is set if ($country === null || (is_array($country) && count($country) === 0)) { @@ -684,64 +745,54 @@ public function faxLineAreaCodeGetRequest(string $country, string $state = null, } $resourcePath = '/fax_line/area_codes'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // query params - if ($country !== null) { - if ('form' === 'form' && is_array($country)) { - foreach ($country as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['country'] = $country; - } - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $country, + 'country', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); // query params - if ($state !== null) { - if ('form' === 'form' && is_array($state)) { - foreach ($state as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['state'] = $state; - } - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $state, + 'state', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); // query params - if ($province !== null) { - if ('form' === 'form' && is_array($province)) { - foreach ($province as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['province'] = $province; - } - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $province, + 'province', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); // query params - if ($city !== null) { - if ('form' === 'form' && is_array($city)) { - foreach ($city as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['city'] = $city; - } - } - - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $city, + 'city', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -759,18 +810,19 @@ public function faxLineAreaCodeGetRequest(string $country, string $state = null, // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -790,11 +842,11 @@ public function faxLineAreaCodeGetRequest(string $country, string $state = null, $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'GET', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -807,14 +859,13 @@ public function faxLineAreaCodeGetRequest(string $country, string $state = null, * * @param Model\FaxLineCreateRequest $fax_line_create_request fax_line_create_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\FaxLineResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function faxLineCreate(Model\FaxLineCreateRequest $fax_line_create_request) { list($response) = $this->faxLineCreateWithHttpInfo($fax_line_create_request); - return $response; } @@ -824,14 +875,16 @@ public function faxLineCreate(Model\FaxLineCreateRequest $fax_line_create_reques * Purchase Fax Line * * @param Model\FaxLineCreateRequest $fax_line_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineCreate'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\FaxLineResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::faxLineCreate. This method will eventually become unavailable */ - public function faxLineCreateWithHttpInfo(Model\FaxLineCreateRequest $fax_line_create_request) + public function faxLineCreateWithHttpInfo(Model\FaxLineCreateRequest $fax_line_create_request, string $contentType = self::contentTypes['faxLineCreate'][0]) { - $request = $this->faxLineCreateRequest($fax_line_create_request); + $request = $this->faxLineCreateRequest($fax_line_create_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -841,14 +894,14 @@ public function faxLineCreateWithHttpInfo(Model\FaxLineCreateRequest $fax_line_c } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -861,51 +914,73 @@ public function faxLineCreateWithHttpInfo(Model\FaxLineCreateRequest $fax_line_c sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\FaxLineResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\FaxLineResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\FaxLineResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\FaxLineResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\FaxLineResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\FaxLineResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -914,28 +989,19 @@ public function faxLineCreateWithHttpInfo(Model\FaxLineCreateRequest $fax_line_c $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\FaxLineResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\FaxLineResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -946,13 +1012,15 @@ public function faxLineCreateWithHttpInfo(Model\FaxLineCreateRequest $fax_line_c * Purchase Fax Line * * @param Model\FaxLineCreateRequest $fax_line_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineCreate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::faxLineCreate. This method will eventually become unavailable */ - public function faxLineCreateAsync(Model\FaxLineCreateRequest $fax_line_create_request) + public function faxLineCreateAsync(Model\FaxLineCreateRequest $fax_line_create_request, string $contentType = self::contentTypes['faxLineCreate'][0]) { - return $this->faxLineCreateAsyncWithHttpInfo($fax_line_create_request) + return $this->faxLineCreateAsyncWithHttpInfo($fax_line_create_request, $contentType) ->then( function ($response) { return $response[0]; @@ -966,23 +1034,28 @@ function ($response) { * Purchase Fax Line * * @param Model\FaxLineCreateRequest $fax_line_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineCreate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::faxLineCreate. This method will eventually become unavailable */ - public function faxLineCreateAsyncWithHttpInfo(Model\FaxLineCreateRequest $fax_line_create_request) + public function faxLineCreateAsyncWithHttpInfo(Model\FaxLineCreateRequest $fax_line_create_request, string $contentType = self::contentTypes['faxLineCreate'][0]) { $returnType = '\Dropbox\Sign\Model\FaxLineResponse'; - $request = $this->faxLineCreateRequest($fax_line_create_request); + $request = $this->faxLineCreateRequest($fax_line_create_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -1002,7 +1075,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -1012,11 +1085,13 @@ function ($exception) { * Create request for operation 'faxLineCreate' * * @param Model\FaxLineCreateRequest $fax_line_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineCreate'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::faxLineCreate. This method will eventually become unavailable */ - public function faxLineCreateRequest(Model\FaxLineCreateRequest $fax_line_create_request) + public function faxLineCreateRequest(Model\FaxLineCreateRequest $fax_line_create_request, string $contentType = self::contentTypes['faxLineCreate'][0]) { // verify the required parameter 'fax_line_create_request' is set if ($fax_line_create_request === null || (is_array($fax_line_create_request) && count($fax_line_create_request) === 0)) { @@ -1026,9 +1101,11 @@ public function faxLineCreateRequest(Model\FaxLineCreateRequest $fax_line_create } $resourcePath = '/fax_line/create'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $fax_line_create_request @@ -1036,21 +1113,17 @@ public function faxLineCreateRequest(Model\FaxLineCreateRequest $fax_line_create $multipart = !empty($formParams); - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($fax_line_create_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($fax_line_create_request)); } else { $httpBody = $fax_line_create_request; } @@ -1069,22 +1142,22 @@ public function faxLineCreateRequest(Model\FaxLineCreateRequest $fax_line_create // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $fax_line_create_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -1104,11 +1177,11 @@ public function faxLineCreateRequest(Model\FaxLineCreateRequest $fax_line_create $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1121,9 +1194,8 @@ public function faxLineCreateRequest(Model\FaxLineCreateRequest $fax_line_create * * @param Model\FaxLineDeleteRequest $fax_line_delete_request fax_line_delete_request (required) * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException - * @return void */ public function faxLineDelete(Model\FaxLineDeleteRequest $fax_line_delete_request) { @@ -1136,14 +1208,16 @@ public function faxLineDelete(Model\FaxLineDeleteRequest $fax_line_delete_reques * Delete Fax Line * * @param Model\FaxLineDeleteRequest $fax_line_delete_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineDelete'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::faxLineDelete. This method will eventually become unavailable */ - public function faxLineDeleteWithHttpInfo(Model\FaxLineDeleteRequest $fax_line_delete_request) + public function faxLineDeleteWithHttpInfo(Model\FaxLineDeleteRequest $fax_line_delete_request, string $contentType = self::contentTypes['faxLineDelete'][0]) { - $request = $this->faxLineDeleteRequest($fax_line_delete_request); + $request = $this->faxLineDeleteRequest($fax_line_delete_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -1153,14 +1227,14 @@ public function faxLineDeleteWithHttpInfo(Model\FaxLineDeleteRequest $fax_line_d } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -1173,29 +1247,21 @@ public function faxLineDeleteWithHttpInfo(Model\FaxLineDeleteRequest $fax_line_d sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } return [null, $statusCode, $response->getHeaders()]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { } - throw $e; } } @@ -1206,13 +1272,15 @@ public function faxLineDeleteWithHttpInfo(Model\FaxLineDeleteRequest $fax_line_d * Delete Fax Line * * @param Model\FaxLineDeleteRequest $fax_line_delete_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineDelete'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::faxLineDelete. This method will eventually become unavailable */ - public function faxLineDeleteAsync(Model\FaxLineDeleteRequest $fax_line_delete_request) + public function faxLineDeleteAsync(Model\FaxLineDeleteRequest $fax_line_delete_request, string $contentType = self::contentTypes['faxLineDelete'][0]) { - return $this->faxLineDeleteAsyncWithHttpInfo($fax_line_delete_request) + return $this->faxLineDeleteAsyncWithHttpInfo($fax_line_delete_request, $contentType) ->then( function ($response) { return $response[0]; @@ -1226,14 +1294,16 @@ function ($response) { * Delete Fax Line * * @param Model\FaxLineDeleteRequest $fax_line_delete_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineDelete'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::faxLineDelete. This method will eventually become unavailable */ - public function faxLineDeleteAsyncWithHttpInfo(Model\FaxLineDeleteRequest $fax_line_delete_request) + public function faxLineDeleteAsyncWithHttpInfo(Model\FaxLineDeleteRequest $fax_line_delete_request, string $contentType = self::contentTypes['faxLineDelete'][0]) { $returnType = ''; - $request = $this->faxLineDeleteRequest($fax_line_delete_request); + $request = $this->faxLineDeleteRequest($fax_line_delete_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1252,7 +1322,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -1262,11 +1332,13 @@ function ($exception) { * Create request for operation 'faxLineDelete' * * @param Model\FaxLineDeleteRequest $fax_line_delete_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineDelete'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::faxLineDelete. This method will eventually become unavailable */ - public function faxLineDeleteRequest(Model\FaxLineDeleteRequest $fax_line_delete_request) + public function faxLineDeleteRequest(Model\FaxLineDeleteRequest $fax_line_delete_request, string $contentType = self::contentTypes['faxLineDelete'][0]) { // verify the required parameter 'fax_line_delete_request' is set if ($fax_line_delete_request === null || (is_array($fax_line_delete_request) && count($fax_line_delete_request) === 0)) { @@ -1276,9 +1348,11 @@ public function faxLineDeleteRequest(Model\FaxLineDeleteRequest $fax_line_delete } $resourcePath = '/fax_line'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $fax_line_delete_request @@ -1286,21 +1360,17 @@ public function faxLineDeleteRequest(Model\FaxLineDeleteRequest $fax_line_delete $multipart = !empty($formParams); - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($fax_line_delete_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($fax_line_delete_request)); } else { $httpBody = $fax_line_delete_request; } @@ -1319,22 +1389,22 @@ public function faxLineDeleteRequest(Model\FaxLineDeleteRequest $fax_line_delete // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $fax_line_delete_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -1354,11 +1424,11 @@ public function faxLineDeleteRequest(Model\FaxLineDeleteRequest $fax_line_delete $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'DELETE', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1371,14 +1441,13 @@ public function faxLineDeleteRequest(Model\FaxLineDeleteRequest $fax_line_delete * * @param string $number The Fax Line number. (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\FaxLineResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function faxLineGet(string $number) { list($response) = $this->faxLineGetWithHttpInfo($number); - return $response; } @@ -1387,15 +1456,17 @@ public function faxLineGet(string $number) * * Get Fax Line * - * @param string $number The Fax Line number. (required) + * @param string $number The Fax Line number. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineGet'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\FaxLineResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::faxLineGet. This method will eventually become unavailable */ - public function faxLineGetWithHttpInfo(string $number) + public function faxLineGetWithHttpInfo(string $number, string $contentType = self::contentTypes['faxLineGet'][0]) { - $request = $this->faxLineGetRequest($number); + $request = $this->faxLineGetRequest($number, $contentType); try { $options = $this->createHttpClientOption(); @@ -1405,14 +1476,14 @@ public function faxLineGetWithHttpInfo(string $number) } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -1425,51 +1496,73 @@ public function faxLineGetWithHttpInfo(string $number) sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\FaxLineResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\FaxLineResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\FaxLineResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\FaxLineResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\FaxLineResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\FaxLineResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -1478,28 +1571,19 @@ public function faxLineGetWithHttpInfo(string $number) $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\FaxLineResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\FaxLineResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -1509,14 +1593,16 @@ public function faxLineGetWithHttpInfo(string $number) * * Get Fax Line * - * @param string $number The Fax Line number. (required) + * @param string $number The Fax Line number. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineGet'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::faxLineGet. This method will eventually become unavailable */ - public function faxLineGetAsync(string $number) + public function faxLineGetAsync(string $number, string $contentType = self::contentTypes['faxLineGet'][0]) { - return $this->faxLineGetAsyncWithHttpInfo($number) + return $this->faxLineGetAsyncWithHttpInfo($number, $contentType) ->then( function ($response) { return $response[0]; @@ -1529,24 +1615,29 @@ function ($response) { * * Get Fax Line * - * @param string $number The Fax Line number. (required) + * @param string $number The Fax Line number. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineGet'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::faxLineGet. This method will eventually become unavailable */ - public function faxLineGetAsyncWithHttpInfo(string $number) + public function faxLineGetAsyncWithHttpInfo(string $number, string $contentType = self::contentTypes['faxLineGet'][0]) { $returnType = '\Dropbox\Sign\Model\FaxLineResponse'; - $request = $this->faxLineGetRequest($number); + $request = $this->faxLineGetRequest($number, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -1566,7 +1657,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -1575,12 +1666,14 @@ function ($exception) { /** * Create request for operation 'faxLineGet' * - * @param string $number The Fax Line number. (required) + * @param string $number The Fax Line number. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineGet'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::faxLineGet. This method will eventually become unavailable */ - public function faxLineGetRequest(string $number) + public function faxLineGetRequest(string $number, string $contentType = self::contentTypes['faxLineGet'][0]) { // verify the required parameter 'number' is set if ($number === null || (is_array($number) && count($number) === 0)) { @@ -1590,34 +1683,27 @@ public function faxLineGetRequest(string $number) } $resourcePath = '/fax_line'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // query params - if ($number !== null) { - if ('form' === 'form' && is_array($number)) { - foreach ($number as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['number'] = $number; - } - } - - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $number, + 'number', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -1635,18 +1721,19 @@ public function faxLineGetRequest(string $number) // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -1666,11 +1753,11 @@ public function faxLineGetRequest(string $number) $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'GET', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1681,19 +1768,18 @@ public function faxLineGetRequest(string $number) * * List Fax Lines * - * @param string $account_id Account ID (optional) - * @param int $page Page (optional, default to 1) - * @param int $page_size Page size (optional, default to 20) - * @param bool $show_team_lines Show team lines (optional) + * @param string $account_id Account ID (optional) + * @param int $page Page (optional, default to 1) + * @param int $page_size Page size (optional, default to 20) + * @param bool $show_team_lines Show team lines (optional) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\FaxLineListResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function faxLineList(string $account_id = null, int $page = 1, int $page_size = 20, bool $show_team_lines = null) { list($response) = $this->faxLineListWithHttpInfo($account_id, $page, $page_size, $show_team_lines); - return $response; } @@ -1702,18 +1788,20 @@ public function faxLineList(string $account_id = null, int $page = 1, int $page_ * * List Fax Lines * - * @param string $account_id Account ID (optional) - * @param int $page Page (optional, default to 1) - * @param int $page_size Page size (optional, default to 20) - * @param bool $show_team_lines Show team lines (optional) + * @param string $account_id Account ID (optional) + * @param int $page Page (optional, default to 1) + * @param int $page_size Page size (optional, default to 20) + * @param bool $show_team_lines Show team lines (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineList'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\FaxLineListResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::faxLineList. This method will eventually become unavailable */ - public function faxLineListWithHttpInfo(string $account_id = null, int $page = 1, int $page_size = 20, bool $show_team_lines = null) + public function faxLineListWithHttpInfo(string $account_id = null, int $page = 1, int $page_size = 20, bool $show_team_lines = null, string $contentType = self::contentTypes['faxLineList'][0]) { - $request = $this->faxLineListRequest($account_id, $page, $page_size, $show_team_lines); + $request = $this->faxLineListRequest($account_id, $page, $page_size, $show_team_lines, $contentType); try { $options = $this->createHttpClientOption(); @@ -1723,14 +1811,14 @@ public function faxLineListWithHttpInfo(string $account_id = null, int $page = 1 } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -1743,51 +1831,73 @@ public function faxLineListWithHttpInfo(string $account_id = null, int $page = 1 sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\FaxLineListResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\FaxLineListResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\FaxLineListResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\FaxLineListResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\FaxLineListResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\FaxLineListResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -1796,28 +1906,19 @@ public function faxLineListWithHttpInfo(string $account_id = null, int $page = 1 $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\FaxLineListResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\FaxLineListResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -1827,17 +1928,19 @@ public function faxLineListWithHttpInfo(string $account_id = null, int $page = 1 * * List Fax Lines * - * @param string $account_id Account ID (optional) - * @param int $page Page (optional, default to 1) - * @param int $page_size Page size (optional, default to 20) - * @param bool $show_team_lines Show team lines (optional) + * @param string $account_id Account ID (optional) + * @param int $page Page (optional, default to 1) + * @param int $page_size Page size (optional, default to 20) + * @param bool $show_team_lines Show team lines (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineList'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::faxLineList. This method will eventually become unavailable */ - public function faxLineListAsync(string $account_id = null, int $page = 1, int $page_size = 20, bool $show_team_lines = null) + public function faxLineListAsync(string $account_id = null, int $page = 1, int $page_size = 20, bool $show_team_lines = null, string $contentType = self::contentTypes['faxLineList'][0]) { - return $this->faxLineListAsyncWithHttpInfo($account_id, $page, $page_size, $show_team_lines) + return $this->faxLineListAsyncWithHttpInfo($account_id, $page, $page_size, $show_team_lines, $contentType) ->then( function ($response) { return $response[0]; @@ -1850,27 +1953,32 @@ function ($response) { * * List Fax Lines * - * @param string $account_id Account ID (optional) - * @param int $page Page (optional, default to 1) - * @param int $page_size Page size (optional, default to 20) - * @param bool $show_team_lines Show team lines (optional) + * @param string $account_id Account ID (optional) + * @param int $page Page (optional, default to 1) + * @param int $page_size Page size (optional, default to 20) + * @param bool $show_team_lines Show team lines (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineList'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::faxLineList. This method will eventually become unavailable */ - public function faxLineListAsyncWithHttpInfo(string $account_id = null, int $page = 1, int $page_size = 20, bool $show_team_lines = null) + public function faxLineListAsyncWithHttpInfo(string $account_id = null, int $page = 1, int $page_size = 20, bool $show_team_lines = null, string $contentType = self::contentTypes['faxLineList'][0]) { $returnType = '\Dropbox\Sign\Model\FaxLineListResponse'; - $request = $this->faxLineListRequest($account_id, $page, $page_size, $show_team_lines); + $request = $this->faxLineListRequest($account_id, $page, $page_size, $show_team_lines, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -1890,7 +1998,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -1899,75 +2007,67 @@ function ($exception) { /** * Create request for operation 'faxLineList' * - * @param string $account_id Account ID (optional) - * @param int $page Page (optional, default to 1) - * @param int $page_size Page size (optional, default to 20) - * @param bool $show_team_lines Show team lines (optional) + * @param string $account_id Account ID (optional) + * @param int $page Page (optional, default to 1) + * @param int $page_size Page size (optional, default to 20) + * @param bool $show_team_lines Show team lines (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineList'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::faxLineList. This method will eventually become unavailable */ - public function faxLineListRequest(string $account_id = null, int $page = 1, int $page_size = 20, bool $show_team_lines = null) + public function faxLineListRequest(string $account_id = null, int $page = 1, int $page_size = 20, bool $show_team_lines = null, string $contentType = self::contentTypes['faxLineList'][0]) { $resourcePath = '/fax_line/list'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // query params - if ($account_id !== null) { - if ('form' === 'form' && is_array($account_id)) { - foreach ($account_id as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['account_id'] = $account_id; - } - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $account_id, + 'account_id', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); // query params - if ($page !== null) { - if ('form' === 'form' && is_array($page)) { - foreach ($page as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['page'] = $page; - } - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); // query params - if ($page_size !== null) { - if ('form' === 'form' && is_array($page_size)) { - foreach ($page_size as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['page_size'] = $page_size; - } - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'page_size', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); // query params - if ($show_team_lines !== null) { - if ('form' === 'form' && is_array($show_team_lines)) { - foreach ($show_team_lines as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['show_team_lines'] = $show_team_lines; - } - } - - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $show_team_lines, + 'show_team_lines', // param base name + 'boolean', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -1985,18 +2085,19 @@ public function faxLineListRequest(string $account_id = null, int $page = 1, int // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -2016,11 +2117,11 @@ public function faxLineListRequest(string $account_id = null, int $page = 1, int $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'GET', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -2033,14 +2134,13 @@ public function faxLineListRequest(string $account_id = null, int $page = 1, int * * @param Model\FaxLineRemoveUserRequest $fax_line_remove_user_request fax_line_remove_user_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\FaxLineResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function faxLineRemoveUser(Model\FaxLineRemoveUserRequest $fax_line_remove_user_request) { list($response) = $this->faxLineRemoveUserWithHttpInfo($fax_line_remove_user_request); - return $response; } @@ -2050,14 +2150,16 @@ public function faxLineRemoveUser(Model\FaxLineRemoveUserRequest $fax_line_remov * Remove Fax Line Access * * @param Model\FaxLineRemoveUserRequest $fax_line_remove_user_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineRemoveUser'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\FaxLineResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::faxLineRemoveUser. This method will eventually become unavailable */ - public function faxLineRemoveUserWithHttpInfo(Model\FaxLineRemoveUserRequest $fax_line_remove_user_request) + public function faxLineRemoveUserWithHttpInfo(Model\FaxLineRemoveUserRequest $fax_line_remove_user_request, string $contentType = self::contentTypes['faxLineRemoveUser'][0]) { - $request = $this->faxLineRemoveUserRequest($fax_line_remove_user_request); + $request = $this->faxLineRemoveUserRequest($fax_line_remove_user_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -2067,14 +2169,14 @@ public function faxLineRemoveUserWithHttpInfo(Model\FaxLineRemoveUserRequest $fa } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -2087,51 +2189,73 @@ public function faxLineRemoveUserWithHttpInfo(Model\FaxLineRemoveUserRequest $fa sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\FaxLineResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\FaxLineResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\FaxLineResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\FaxLineResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\FaxLineResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\FaxLineResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -2140,28 +2264,19 @@ public function faxLineRemoveUserWithHttpInfo(Model\FaxLineRemoveUserRequest $fa $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\FaxLineResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\FaxLineResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -2172,13 +2287,15 @@ public function faxLineRemoveUserWithHttpInfo(Model\FaxLineRemoveUserRequest $fa * Remove Fax Line Access * * @param Model\FaxLineRemoveUserRequest $fax_line_remove_user_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineRemoveUser'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::faxLineRemoveUser. This method will eventually become unavailable */ - public function faxLineRemoveUserAsync(Model\FaxLineRemoveUserRequest $fax_line_remove_user_request) + public function faxLineRemoveUserAsync(Model\FaxLineRemoveUserRequest $fax_line_remove_user_request, string $contentType = self::contentTypes['faxLineRemoveUser'][0]) { - return $this->faxLineRemoveUserAsyncWithHttpInfo($fax_line_remove_user_request) + return $this->faxLineRemoveUserAsyncWithHttpInfo($fax_line_remove_user_request, $contentType) ->then( function ($response) { return $response[0]; @@ -2192,23 +2309,28 @@ function ($response) { * Remove Fax Line Access * * @param Model\FaxLineRemoveUserRequest $fax_line_remove_user_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineRemoveUser'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::faxLineRemoveUser. This method will eventually become unavailable */ - public function faxLineRemoveUserAsyncWithHttpInfo(Model\FaxLineRemoveUserRequest $fax_line_remove_user_request) + public function faxLineRemoveUserAsyncWithHttpInfo(Model\FaxLineRemoveUserRequest $fax_line_remove_user_request, string $contentType = self::contentTypes['faxLineRemoveUser'][0]) { $returnType = '\Dropbox\Sign\Model\FaxLineResponse'; - $request = $this->faxLineRemoveUserRequest($fax_line_remove_user_request); + $request = $this->faxLineRemoveUserRequest($fax_line_remove_user_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -2228,7 +2350,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -2238,11 +2360,13 @@ function ($exception) { * Create request for operation 'faxLineRemoveUser' * * @param Model\FaxLineRemoveUserRequest $fax_line_remove_user_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['faxLineRemoveUser'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::faxLineRemoveUser. This method will eventually become unavailable */ - public function faxLineRemoveUserRequest(Model\FaxLineRemoveUserRequest $fax_line_remove_user_request) + public function faxLineRemoveUserRequest(Model\FaxLineRemoveUserRequest $fax_line_remove_user_request, string $contentType = self::contentTypes['faxLineRemoveUser'][0]) { // verify the required parameter 'fax_line_remove_user_request' is set if ($fax_line_remove_user_request === null || (is_array($fax_line_remove_user_request) && count($fax_line_remove_user_request) === 0)) { @@ -2252,9 +2376,11 @@ public function faxLineRemoveUserRequest(Model\FaxLineRemoveUserRequest $fax_lin } $resourcePath = '/fax_line/remove_user'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $fax_line_remove_user_request @@ -2262,21 +2388,17 @@ public function faxLineRemoveUserRequest(Model\FaxLineRemoveUserRequest $fax_lin $multipart = !empty($formParams); - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($fax_line_remove_user_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($fax_line_remove_user_request)); } else { $httpBody = $fax_line_remove_user_request; } @@ -2295,22 +2417,22 @@ public function faxLineRemoveUserRequest(Model\FaxLineRemoveUserRequest $fax_lin // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $fax_line_remove_user_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -2330,11 +2452,11 @@ public function faxLineRemoveUserRequest(Model\FaxLineRemoveUserRequest $fax_lin $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'PUT', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -2343,8 +2465,8 @@ public function faxLineRemoveUserRequest(Model\FaxLineRemoveUserRequest $fax_lin /** * Create http client option * - * @throws RuntimeException on file opening failure * @return array of http client options + * @throws RuntimeException on file opening failure */ protected function createHttpClientOption() { @@ -2358,4 +2480,66 @@ protected function createHttpClientOption() return $options; } + + /** + * @return object|array|null + */ + private function handleRangeCodeResponse( + ResponseInterface $response, + string $rangeCode, + string $returnDataType + ) { + $statusCode = $response->getStatusCode(); + $rangeCodeLeft = (int)(substr($rangeCode, 0, 1) . '00'); + $rangeCodeRight = (int)(substr($rangeCode, 0, 1) . '99'); + + if ( + $statusCode < $rangeCodeLeft + || $statusCode > $rangeCodeRight + ) { + return null; + } + + if ($returnDataType === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + } + + return [ + ObjectSerializer::deserialize($content, $returnDataType, []), + $statusCode, + $response->getHeaders(), + ]; + } + + /** + * @return object|array|null + */ + private function handleRangeCodeException( + ApiException $e, + string $rangeCode, + string $exceptionDataType + ): bool { + $statusCode = $e->getCode(); + $rangeCodeLeft = (int)(substr($rangeCode, 0, 1) . '00'); + $rangeCodeRight = (int)(substr($rangeCode, 0, 1) . '99'); + + if ( + $statusCode < $rangeCodeLeft + || $statusCode > $rangeCodeRight + ) { + return false; + } + + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + $exceptionDataType, + $e->getResponseHeaders() + ); + + $e->setResponseObject($data); + + return true; + } } diff --git a/sdks/php/src/Api/OAuthApi.php b/sdks/php/src/Api/OAuthApi.php index 8f52cb8a9..6fa77398a 100644 --- a/sdks/php/src/Api/OAuthApi.php +++ b/sdks/php/src/Api/OAuthApi.php @@ -4,7 +4,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -16,7 +15,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -36,11 +35,11 @@ use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Promise; -use GuzzleHttp\Psr7; +use GuzzleHttp\Psr7\MultipartStream; +use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; -use GuzzleHttp\Utils; use InvalidArgumentException; +use JsonException; use Psr\Http\Message\ResponseInterface; use RuntimeException; @@ -48,34 +47,35 @@ * OAuthApi Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ class OAuthApi { - /** - * @var ClientInterface - */ + /** @var ClientInterface */ protected $client; - /** - * @var Configuration - */ + /** @var Configuration */ protected $config; - /** - * @var HeaderSelector - */ + /** @var HeaderSelector */ protected $headerSelector; - /** - * @var int Host index - */ + /** @var int Host index */ protected $hostIndex; /** - * @var ResponseInterface|null + * @var string[] * */ + public const contentTypes = [ + 'oauthTokenGenerate' => [ + 'application/json', + ], + 'oauthTokenRefresh' => [ + 'application/json', + ], + ]; + + /** @var ResponseInterface|null */ protected $response; /** @@ -97,6 +97,7 @@ public function __construct( * Set the host index * * @param int $hostIndex Host index (required) + * @deprecated To be made private in the future */ public function setHostIndex(int $hostIndex): void { @@ -107,6 +108,7 @@ public function setHostIndex(int $hostIndex): void * Get the host index * * @return int Host index + * @deprecated To be made private in the future */ public function getHostIndex() { @@ -134,19 +136,19 @@ public function getResponse() * * OAuth Token Generate * - * This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. + * if needed, use the 'variables' parameter to pass variables to the host. * URL: https://app.hellosign.com * * @param Model\OAuthTokenGenerateRequest $o_auth_token_generate_request o_auth_token_generate_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\OAuthTokenResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function oauthTokenGenerate(Model\OAuthTokenGenerateRequest $o_auth_token_generate_request) { list($response) = $this->oauthTokenGenerateWithHttpInfo($o_auth_token_generate_request); - return $response; } @@ -155,18 +157,23 @@ public function oauthTokenGenerate(Model\OAuthTokenGenerateRequest $o_auth_token * * OAuth Token Generate * - * This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. + * if needed, use the 'variables' parameter to pass variables to the host. * URL: https://app.hellosign.com * * @param Model\OAuthTokenGenerateRequest $o_auth_token_generate_request (required) + * @param int|null $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead + * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['oauthTokenGenerate'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\OAuthTokenResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::oauthTokenGenerate. This method will eventually become unavailable */ - public function oauthTokenGenerateWithHttpInfo(Model\OAuthTokenGenerateRequest $o_auth_token_generate_request) + public function oauthTokenGenerateWithHttpInfo(Model\OAuthTokenGenerateRequest $o_auth_token_generate_request, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['oauthTokenGenerate'][0]) { - $request = $this->oauthTokenGenerateRequest($o_auth_token_generate_request); + $request = $this->oauthTokenGenerateRequest($o_auth_token_generate_request, $hostIndex, $variables, $contentType); try { $options = $this->createHttpClientOption(); @@ -176,14 +183,14 @@ public function oauthTokenGenerateWithHttpInfo(Model\OAuthTokenGenerateRequest $ } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -196,35 +203,64 @@ public function oauthTokenGenerateWithHttpInfo(Model\OAuthTokenGenerateRequest $ sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\OAuthTokenResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\OAuthTokenResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\OAuthTokenResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\OAuthTokenResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\OAuthTokenResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\OAuthTokenResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -233,17 +269,16 @@ public function oauthTokenGenerateWithHttpInfo(Model\OAuthTokenGenerateRequest $ $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\OAuthTokenResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\OAuthTokenResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -253,17 +288,22 @@ public function oauthTokenGenerateWithHttpInfo(Model\OAuthTokenGenerateRequest $ * * OAuth Token Generate * - * This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. + * if needed, use the 'variables' parameter to pass variables to the host. * URL: https://app.hellosign.com * * @param Model\OAuthTokenGenerateRequest $o_auth_token_generate_request (required) + * @param int|null $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead + * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['oauthTokenGenerate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::oauthTokenGenerate. This method will eventually become unavailable */ - public function oauthTokenGenerateAsync(Model\OAuthTokenGenerateRequest $o_auth_token_generate_request) + public function oauthTokenGenerateAsync(Model\OAuthTokenGenerateRequest $o_auth_token_generate_request, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['oauthTokenGenerate'][0]) { - return $this->oauthTokenGenerateAsyncWithHttpInfo($o_auth_token_generate_request) + return $this->oauthTokenGenerateAsyncWithHttpInfo($o_auth_token_generate_request, $hostIndex, $variables, $contentType) ->then( function ($response) { return $response[0]; @@ -276,27 +316,35 @@ function ($response) { * * OAuth Token Generate * - * This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. + * if needed, use the 'variables' parameter to pass variables to the host. * URL: https://app.hellosign.com * * @param Model\OAuthTokenGenerateRequest $o_auth_token_generate_request (required) + * @param int|null $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead + * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['oauthTokenGenerate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::oauthTokenGenerate. This method will eventually become unavailable */ - public function oauthTokenGenerateAsyncWithHttpInfo(Model\OAuthTokenGenerateRequest $o_auth_token_generate_request) + public function oauthTokenGenerateAsyncWithHttpInfo(Model\OAuthTokenGenerateRequest $o_auth_token_generate_request, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['oauthTokenGenerate'][0]) { $returnType = '\Dropbox\Sign\Model\OAuthTokenResponse'; - $request = $this->oauthTokenGenerateRequest($o_auth_token_generate_request); + $request = $this->oauthTokenGenerateRequest($o_auth_token_generate_request, $hostIndex, $variables, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -316,7 +364,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -325,15 +373,20 @@ function ($exception) { /** * Create request for operation 'oauthTokenGenerate' * - * This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. + * if needed, use the 'variables' parameter to pass variables to the host. * URL: https://app.hellosign.com * * @param Model\OAuthTokenGenerateRequest $o_auth_token_generate_request (required) + * @param int|null $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead + * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['oauthTokenGenerate'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::oauthTokenGenerate. This method will eventually become unavailable */ - public function oauthTokenGenerateRequest(Model\OAuthTokenGenerateRequest $o_auth_token_generate_request) + public function oauthTokenGenerateRequest(Model\OAuthTokenGenerateRequest $o_auth_token_generate_request, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['oauthTokenGenerate'][0]) { // verify the required parameter 'o_auth_token_generate_request' is set if ($o_auth_token_generate_request === null || (is_array($o_auth_token_generate_request) && count($o_auth_token_generate_request) === 0)) { @@ -343,9 +396,11 @@ public function oauthTokenGenerateRequest(Model\OAuthTokenGenerateRequest $o_aut } $resourcePath = '/oauth/token'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $o_auth_token_generate_request @@ -353,21 +408,17 @@ public function oauthTokenGenerateRequest(Model\OAuthTokenGenerateRequest $o_aut $multipart = !empty($formParams); - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($o_auth_token_generate_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($o_auth_token_generate_request)); } else { $httpBody = $o_auth_token_generate_request; } @@ -386,22 +437,22 @@ public function oauthTokenGenerateRequest(Model\OAuthTokenGenerateRequest $o_aut // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $o_auth_token_generate_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -416,15 +467,19 @@ public function oauthTokenGenerateRequest(Model\OAuthTokenGenerateRequest $o_aut $headers ); - $operationHosts = ['https://app.hellosign.com']; - if ($this->hostIndex < 0 || $this->hostIndex >= sizeof($operationHosts)) { - throw new InvalidArgumentException("Invalid index {$this->hostIndex} when selecting the host. Must be less than " . sizeof($operationHosts)); + // Preserve the original behavior of server indexing. + if ($hostIndex === null) { + $hostIndex = $this->hostIndex; } - $operationHost = $operationHosts[$this->hostIndex]; - $query = Psr7\Query::build($queryParams); + $hostSettings = $this->getHostSettingsForoauthTokenGenerate(); - return new Psr7\Request( + if ($hostIndex < 0 || $hostIndex >= count($hostSettings)) { + throw new InvalidArgumentException("Invalid index {$hostIndex} when selecting the host. Must be less than " . count($hostSettings)); + } + $operationHost = Configuration::getHostString($hostSettings, $hostIndex, $variables); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, @@ -432,24 +487,39 @@ public function oauthTokenGenerateRequest(Model\OAuthTokenGenerateRequest $o_aut ); } + /** + * Returns an array of host settings for Operation oauthTokenGenerate + * + * @return array an array of host settings + */ + protected function getHostSettingsForoauthTokenGenerate(): array + { + return [ + [ + 'url' => 'https://app.hellosign.com', + 'description' => 'No description provided', + ], + ]; + } + /** * Operation oauthTokenRefresh * * OAuth Token Refresh * - * This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. + * if needed, use the 'variables' parameter to pass variables to the host. * URL: https://app.hellosign.com * * @param Model\OAuthTokenRefreshRequest $o_auth_token_refresh_request o_auth_token_refresh_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\OAuthTokenResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function oauthTokenRefresh(Model\OAuthTokenRefreshRequest $o_auth_token_refresh_request) { list($response) = $this->oauthTokenRefreshWithHttpInfo($o_auth_token_refresh_request); - return $response; } @@ -458,18 +528,23 @@ public function oauthTokenRefresh(Model\OAuthTokenRefreshRequest $o_auth_token_r * * OAuth Token Refresh * - * This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. + * if needed, use the 'variables' parameter to pass variables to the host. * URL: https://app.hellosign.com * * @param Model\OAuthTokenRefreshRequest $o_auth_token_refresh_request (required) + * @param int|null $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead + * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['oauthTokenRefresh'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\OAuthTokenResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::oauthTokenRefresh. This method will eventually become unavailable */ - public function oauthTokenRefreshWithHttpInfo(Model\OAuthTokenRefreshRequest $o_auth_token_refresh_request) + public function oauthTokenRefreshWithHttpInfo(Model\OAuthTokenRefreshRequest $o_auth_token_refresh_request, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['oauthTokenRefresh'][0]) { - $request = $this->oauthTokenRefreshRequest($o_auth_token_refresh_request); + $request = $this->oauthTokenRefreshRequest($o_auth_token_refresh_request, $hostIndex, $variables, $contentType); try { $options = $this->createHttpClientOption(); @@ -479,14 +554,14 @@ public function oauthTokenRefreshWithHttpInfo(Model\OAuthTokenRefreshRequest $o_ } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -499,35 +574,64 @@ public function oauthTokenRefreshWithHttpInfo(Model\OAuthTokenRefreshRequest $o_ sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\OAuthTokenResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\OAuthTokenResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\OAuthTokenResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\OAuthTokenResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\OAuthTokenResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\OAuthTokenResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -536,17 +640,16 @@ public function oauthTokenRefreshWithHttpInfo(Model\OAuthTokenRefreshRequest $o_ $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\OAuthTokenResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\OAuthTokenResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -556,17 +659,22 @@ public function oauthTokenRefreshWithHttpInfo(Model\OAuthTokenRefreshRequest $o_ * * OAuth Token Refresh * - * This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. + * if needed, use the 'variables' parameter to pass variables to the host. * URL: https://app.hellosign.com * * @param Model\OAuthTokenRefreshRequest $o_auth_token_refresh_request (required) + * @param int|null $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead + * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['oauthTokenRefresh'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::oauthTokenRefresh. This method will eventually become unavailable */ - public function oauthTokenRefreshAsync(Model\OAuthTokenRefreshRequest $o_auth_token_refresh_request) + public function oauthTokenRefreshAsync(Model\OAuthTokenRefreshRequest $o_auth_token_refresh_request, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['oauthTokenRefresh'][0]) { - return $this->oauthTokenRefreshAsyncWithHttpInfo($o_auth_token_refresh_request) + return $this->oauthTokenRefreshAsyncWithHttpInfo($o_auth_token_refresh_request, $hostIndex, $variables, $contentType) ->then( function ($response) { return $response[0]; @@ -579,27 +687,35 @@ function ($response) { * * OAuth Token Refresh * - * This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. + * if needed, use the 'variables' parameter to pass variables to the host. * URL: https://app.hellosign.com * * @param Model\OAuthTokenRefreshRequest $o_auth_token_refresh_request (required) + * @param int|null $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead + * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['oauthTokenRefresh'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::oauthTokenRefresh. This method will eventually become unavailable */ - public function oauthTokenRefreshAsyncWithHttpInfo(Model\OAuthTokenRefreshRequest $o_auth_token_refresh_request) + public function oauthTokenRefreshAsyncWithHttpInfo(Model\OAuthTokenRefreshRequest $o_auth_token_refresh_request, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['oauthTokenRefresh'][0]) { $returnType = '\Dropbox\Sign\Model\OAuthTokenResponse'; - $request = $this->oauthTokenRefreshRequest($o_auth_token_refresh_request); + $request = $this->oauthTokenRefreshRequest($o_auth_token_refresh_request, $hostIndex, $variables, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -619,7 +735,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -628,15 +744,20 @@ function ($exception) { /** * Create request for operation 'oauthTokenRefresh' * - * This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. + * if needed, use the 'variables' parameter to pass variables to the host. * URL: https://app.hellosign.com * * @param Model\OAuthTokenRefreshRequest $o_auth_token_refresh_request (required) + * @param int|null $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead + * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['oauthTokenRefresh'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::oauthTokenRefresh. This method will eventually become unavailable */ - public function oauthTokenRefreshRequest(Model\OAuthTokenRefreshRequest $o_auth_token_refresh_request) + public function oauthTokenRefreshRequest(Model\OAuthTokenRefreshRequest $o_auth_token_refresh_request, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['oauthTokenRefresh'][0]) { // verify the required parameter 'o_auth_token_refresh_request' is set if ($o_auth_token_refresh_request === null || (is_array($o_auth_token_refresh_request) && count($o_auth_token_refresh_request) === 0)) { @@ -646,9 +767,11 @@ public function oauthTokenRefreshRequest(Model\OAuthTokenRefreshRequest $o_auth_ } $resourcePath = '/oauth/token?refresh'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $o_auth_token_refresh_request @@ -656,21 +779,17 @@ public function oauthTokenRefreshRequest(Model\OAuthTokenRefreshRequest $o_auth_ $multipart = !empty($formParams); - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($o_auth_token_refresh_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($o_auth_token_refresh_request)); } else { $httpBody = $o_auth_token_refresh_request; } @@ -689,22 +808,22 @@ public function oauthTokenRefreshRequest(Model\OAuthTokenRefreshRequest $o_auth_ // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $o_auth_token_refresh_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -719,15 +838,19 @@ public function oauthTokenRefreshRequest(Model\OAuthTokenRefreshRequest $o_auth_ $headers ); - $operationHosts = ['https://app.hellosign.com']; - if ($this->hostIndex < 0 || $this->hostIndex >= sizeof($operationHosts)) { - throw new InvalidArgumentException("Invalid index {$this->hostIndex} when selecting the host. Must be less than " . sizeof($operationHosts)); + // Preserve the original behavior of server indexing. + if ($hostIndex === null) { + $hostIndex = $this->hostIndex; } - $operationHost = $operationHosts[$this->hostIndex]; - $query = Psr7\Query::build($queryParams); + $hostSettings = $this->getHostSettingsForoauthTokenRefresh(); - return new Psr7\Request( + if ($hostIndex < 0 || $hostIndex >= count($hostSettings)) { + throw new InvalidArgumentException("Invalid index {$hostIndex} when selecting the host. Must be less than " . count($hostSettings)); + } + $operationHost = Configuration::getHostString($hostSettings, $hostIndex, $variables); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, @@ -735,11 +858,26 @@ public function oauthTokenRefreshRequest(Model\OAuthTokenRefreshRequest $o_auth_ ); } + /** + * Returns an array of host settings for Operation oauthTokenRefresh + * + * @return array an array of host settings + */ + protected function getHostSettingsForoauthTokenRefresh(): array + { + return [ + [ + 'url' => 'https://app.hellosign.com', + 'description' => 'No description provided', + ], + ]; + } + /** * Create http client option * - * @throws RuntimeException on file opening failure * @return array of http client options + * @throws RuntimeException on file opening failure */ protected function createHttpClientOption() { @@ -753,4 +891,66 @@ protected function createHttpClientOption() return $options; } + + /** + * @return object|array|null + */ + private function handleRangeCodeResponse( + ResponseInterface $response, + string $rangeCode, + string $returnDataType + ) { + $statusCode = $response->getStatusCode(); + $rangeCodeLeft = (int)(substr($rangeCode, 0, 1) . '00'); + $rangeCodeRight = (int)(substr($rangeCode, 0, 1) . '99'); + + if ( + $statusCode < $rangeCodeLeft + || $statusCode > $rangeCodeRight + ) { + return null; + } + + if ($returnDataType === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + } + + return [ + ObjectSerializer::deserialize($content, $returnDataType, []), + $statusCode, + $response->getHeaders(), + ]; + } + + /** + * @return object|array|null + */ + private function handleRangeCodeException( + ApiException $e, + string $rangeCode, + string $exceptionDataType + ): bool { + $statusCode = $e->getCode(); + $rangeCodeLeft = (int)(substr($rangeCode, 0, 1) . '00'); + $rangeCodeRight = (int)(substr($rangeCode, 0, 1) . '99'); + + if ( + $statusCode < $rangeCodeLeft + || $statusCode > $rangeCodeRight + ) { + return false; + } + + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + $exceptionDataType, + $e->getResponseHeaders() + ); + + $e->setResponseObject($data); + + return true; + } } diff --git a/sdks/php/src/Api/ReportApi.php b/sdks/php/src/Api/ReportApi.php index 4c4cedadc..987fc25fe 100644 --- a/sdks/php/src/Api/ReportApi.php +++ b/sdks/php/src/Api/ReportApi.php @@ -4,7 +4,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -16,7 +15,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -36,11 +35,11 @@ use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Promise; -use GuzzleHttp\Psr7; +use GuzzleHttp\Psr7\MultipartStream; +use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; -use GuzzleHttp\Utils; use InvalidArgumentException; +use JsonException; use Psr\Http\Message\ResponseInterface; use RuntimeException; @@ -48,34 +47,32 @@ * ReportApi Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ class ReportApi { - /** - * @var ClientInterface - */ + /** @var ClientInterface */ protected $client; - /** - * @var Configuration - */ + /** @var Configuration */ protected $config; - /** - * @var HeaderSelector - */ + /** @var HeaderSelector */ protected $headerSelector; - /** - * @var int Host index - */ + /** @var int Host index */ protected $hostIndex; /** - * @var ResponseInterface|null + * @var string[] * */ + public const contentTypes = [ + 'reportCreate' => [ + 'application/json', + ], + ]; + + /** @var ResponseInterface|null */ protected $response; /** @@ -97,6 +94,7 @@ public function __construct( * Set the host index * * @param int $hostIndex Host index (required) + * @deprecated To be made private in the future */ public function setHostIndex(int $hostIndex): void { @@ -107,6 +105,7 @@ public function setHostIndex(int $hostIndex): void * Get the host index * * @return int Host index + * @deprecated To be made private in the future */ public function getHostIndex() { @@ -136,14 +135,13 @@ public function getResponse() * * @param Model\ReportCreateRequest $report_create_request report_create_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\ReportCreateResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function reportCreate(Model\ReportCreateRequest $report_create_request) { list($response) = $this->reportCreateWithHttpInfo($report_create_request); - return $response; } @@ -153,14 +151,16 @@ public function reportCreate(Model\ReportCreateRequest $report_create_request) * Create Report * * @param Model\ReportCreateRequest $report_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['reportCreate'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\ReportCreateResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::reportCreate. This method will eventually become unavailable */ - public function reportCreateWithHttpInfo(Model\ReportCreateRequest $report_create_request) + public function reportCreateWithHttpInfo(Model\ReportCreateRequest $report_create_request, string $contentType = self::contentTypes['reportCreate'][0]) { - $request = $this->reportCreateRequest($report_create_request); + $request = $this->reportCreateRequest($report_create_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -170,14 +170,14 @@ public function reportCreateWithHttpInfo(Model\ReportCreateRequest $report_creat } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -190,51 +190,73 @@ public function reportCreateWithHttpInfo(Model\ReportCreateRequest $report_creat sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\ReportCreateResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ReportCreateResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\ReportCreateResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\ReportCreateResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ReportCreateResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\ReportCreateResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -243,28 +265,19 @@ public function reportCreateWithHttpInfo(Model\ReportCreateRequest $report_creat $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ReportCreateResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\ReportCreateResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -275,13 +288,15 @@ public function reportCreateWithHttpInfo(Model\ReportCreateRequest $report_creat * Create Report * * @param Model\ReportCreateRequest $report_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['reportCreate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::reportCreate. This method will eventually become unavailable */ - public function reportCreateAsync(Model\ReportCreateRequest $report_create_request) + public function reportCreateAsync(Model\ReportCreateRequest $report_create_request, string $contentType = self::contentTypes['reportCreate'][0]) { - return $this->reportCreateAsyncWithHttpInfo($report_create_request) + return $this->reportCreateAsyncWithHttpInfo($report_create_request, $contentType) ->then( function ($response) { return $response[0]; @@ -295,23 +310,28 @@ function ($response) { * Create Report * * @param Model\ReportCreateRequest $report_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['reportCreate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::reportCreate. This method will eventually become unavailable */ - public function reportCreateAsyncWithHttpInfo(Model\ReportCreateRequest $report_create_request) + public function reportCreateAsyncWithHttpInfo(Model\ReportCreateRequest $report_create_request, string $contentType = self::contentTypes['reportCreate'][0]) { $returnType = '\Dropbox\Sign\Model\ReportCreateResponse'; - $request = $this->reportCreateRequest($report_create_request); + $request = $this->reportCreateRequest($report_create_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -331,7 +351,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -341,11 +361,13 @@ function ($exception) { * Create request for operation 'reportCreate' * * @param Model\ReportCreateRequest $report_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['reportCreate'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::reportCreate. This method will eventually become unavailable */ - public function reportCreateRequest(Model\ReportCreateRequest $report_create_request) + public function reportCreateRequest(Model\ReportCreateRequest $report_create_request, string $contentType = self::contentTypes['reportCreate'][0]) { // verify the required parameter 'report_create_request' is set if ($report_create_request === null || (is_array($report_create_request) && count($report_create_request) === 0)) { @@ -355,9 +377,11 @@ public function reportCreateRequest(Model\ReportCreateRequest $report_create_req } $resourcePath = '/report/create'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $report_create_request @@ -365,21 +389,17 @@ public function reportCreateRequest(Model\ReportCreateRequest $report_create_req $multipart = !empty($formParams); - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($report_create_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($report_create_request)); } else { $httpBody = $report_create_request; } @@ -398,22 +418,22 @@ public function reportCreateRequest(Model\ReportCreateRequest $report_create_req // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $report_create_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -433,11 +453,11 @@ public function reportCreateRequest(Model\ReportCreateRequest $report_create_req $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -446,8 +466,8 @@ public function reportCreateRequest(Model\ReportCreateRequest $report_create_req /** * Create http client option * - * @throws RuntimeException on file opening failure * @return array of http client options + * @throws RuntimeException on file opening failure */ protected function createHttpClientOption() { @@ -461,4 +481,66 @@ protected function createHttpClientOption() return $options; } + + /** + * @return object|array|null + */ + private function handleRangeCodeResponse( + ResponseInterface $response, + string $rangeCode, + string $returnDataType + ) { + $statusCode = $response->getStatusCode(); + $rangeCodeLeft = (int)(substr($rangeCode, 0, 1) . '00'); + $rangeCodeRight = (int)(substr($rangeCode, 0, 1) . '99'); + + if ( + $statusCode < $rangeCodeLeft + || $statusCode > $rangeCodeRight + ) { + return null; + } + + if ($returnDataType === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + } + + return [ + ObjectSerializer::deserialize($content, $returnDataType, []), + $statusCode, + $response->getHeaders(), + ]; + } + + /** + * @return object|array|null + */ + private function handleRangeCodeException( + ApiException $e, + string $rangeCode, + string $exceptionDataType + ): bool { + $statusCode = $e->getCode(); + $rangeCodeLeft = (int)(substr($rangeCode, 0, 1) . '00'); + $rangeCodeRight = (int)(substr($rangeCode, 0, 1) . '99'); + + if ( + $statusCode < $rangeCodeLeft + || $statusCode > $rangeCodeRight + ) { + return false; + } + + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + $exceptionDataType, + $e->getResponseHeaders() + ); + + $e->setResponseObject($data); + + return true; + } } diff --git a/sdks/php/src/Api/SignatureRequestApi.php b/sdks/php/src/Api/SignatureRequestApi.php index 3de87a5da..e8da69d75 100644 --- a/sdks/php/src/Api/SignatureRequestApi.php +++ b/sdks/php/src/Api/SignatureRequestApi.php @@ -4,7 +4,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -16,7 +15,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -36,11 +35,11 @@ use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Promise; -use GuzzleHttp\Psr7; +use GuzzleHttp\Psr7\MultipartStream; +use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; -use GuzzleHttp\Utils; use InvalidArgumentException; +use JsonException; use Psr\Http\Message\ResponseInterface; use RuntimeException; use SplFileObject; @@ -49,34 +48,83 @@ * SignatureRequestApi Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ class SignatureRequestApi { - /** - * @var ClientInterface - */ + /** @var ClientInterface */ protected $client; - /** - * @var Configuration - */ + /** @var Configuration */ protected $config; - /** - * @var HeaderSelector - */ + /** @var HeaderSelector */ protected $headerSelector; - /** - * @var int Host index - */ + /** @var int Host index */ protected $hostIndex; /** - * @var ResponseInterface|null + * @var string[] * */ + public const contentTypes = [ + 'signatureRequestBulkCreateEmbeddedWithTemplate' => [ + 'application/json', + 'multipart/form-data', + ], + 'signatureRequestBulkSendWithTemplate' => [ + 'application/json', + 'multipart/form-data', + ], + 'signatureRequestCancel' => [ + 'application/json', + ], + 'signatureRequestCreateEmbedded' => [ + 'application/json', + 'multipart/form-data', + ], + 'signatureRequestCreateEmbeddedWithTemplate' => [ + 'application/json', + 'multipart/form-data', + ], + 'signatureRequestFiles' => [ + 'application/json', + ], + 'signatureRequestFilesAsDataUri' => [ + 'application/json', + ], + 'signatureRequestFilesAsFileUrl' => [ + 'application/json', + ], + 'signatureRequestGet' => [ + 'application/json', + ], + 'signatureRequestList' => [ + 'application/json', + ], + 'signatureRequestReleaseHold' => [ + 'application/json', + ], + 'signatureRequestRemind' => [ + 'application/json', + ], + 'signatureRequestRemove' => [ + 'application/json', + ], + 'signatureRequestSend' => [ + 'application/json', + 'multipart/form-data', + ], + 'signatureRequestSendWithTemplate' => [ + 'application/json', + 'multipart/form-data', + ], + 'signatureRequestUpdate' => [ + 'application/json', + ], + ]; + + /** @var ResponseInterface|null */ protected $response; /** @@ -98,6 +146,7 @@ public function __construct( * Set the host index * * @param int $hostIndex Host index (required) + * @deprecated To be made private in the future */ public function setHostIndex(int $hostIndex): void { @@ -108,6 +157,7 @@ public function setHostIndex(int $hostIndex): void * Get the host index * * @return int Host index + * @deprecated To be made private in the future */ public function getHostIndex() { @@ -137,14 +187,13 @@ public function getResponse() * * @param Model\SignatureRequestBulkCreateEmbeddedWithTemplateRequest $signature_request_bulk_create_embedded_with_template_request signature_request_bulk_create_embedded_with_template_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\BulkSendJobSendResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function signatureRequestBulkCreateEmbeddedWithTemplate(Model\SignatureRequestBulkCreateEmbeddedWithTemplateRequest $signature_request_bulk_create_embedded_with_template_request) { list($response) = $this->signatureRequestBulkCreateEmbeddedWithTemplateWithHttpInfo($signature_request_bulk_create_embedded_with_template_request); - return $response; } @@ -154,14 +203,16 @@ public function signatureRequestBulkCreateEmbeddedWithTemplate(Model\SignatureRe * Embedded Bulk Send with Template * * @param Model\SignatureRequestBulkCreateEmbeddedWithTemplateRequest $signature_request_bulk_create_embedded_with_template_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestBulkCreateEmbeddedWithTemplate'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\BulkSendJobSendResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::signatureRequestBulkCreateEmbeddedWithTemplate. This method will eventually become unavailable */ - public function signatureRequestBulkCreateEmbeddedWithTemplateWithHttpInfo(Model\SignatureRequestBulkCreateEmbeddedWithTemplateRequest $signature_request_bulk_create_embedded_with_template_request) + public function signatureRequestBulkCreateEmbeddedWithTemplateWithHttpInfo(Model\SignatureRequestBulkCreateEmbeddedWithTemplateRequest $signature_request_bulk_create_embedded_with_template_request, string $contentType = self::contentTypes['signatureRequestBulkCreateEmbeddedWithTemplate'][0]) { - $request = $this->signatureRequestBulkCreateEmbeddedWithTemplateRequest($signature_request_bulk_create_embedded_with_template_request); + $request = $this->signatureRequestBulkCreateEmbeddedWithTemplateRequest($signature_request_bulk_create_embedded_with_template_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -171,14 +222,14 @@ public function signatureRequestBulkCreateEmbeddedWithTemplateWithHttpInfo(Model } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -191,51 +242,73 @@ public function signatureRequestBulkCreateEmbeddedWithTemplateWithHttpInfo(Model sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\BulkSendJobSendResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\BulkSendJobSendResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\BulkSendJobSendResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\BulkSendJobSendResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\BulkSendJobSendResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\BulkSendJobSendResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -244,28 +317,19 @@ public function signatureRequestBulkCreateEmbeddedWithTemplateWithHttpInfo(Model $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\BulkSendJobSendResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\BulkSendJobSendResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -276,13 +340,15 @@ public function signatureRequestBulkCreateEmbeddedWithTemplateWithHttpInfo(Model * Embedded Bulk Send with Template * * @param Model\SignatureRequestBulkCreateEmbeddedWithTemplateRequest $signature_request_bulk_create_embedded_with_template_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestBulkCreateEmbeddedWithTemplate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestBulkCreateEmbeddedWithTemplate. This method will eventually become unavailable */ - public function signatureRequestBulkCreateEmbeddedWithTemplateAsync(Model\SignatureRequestBulkCreateEmbeddedWithTemplateRequest $signature_request_bulk_create_embedded_with_template_request) + public function signatureRequestBulkCreateEmbeddedWithTemplateAsync(Model\SignatureRequestBulkCreateEmbeddedWithTemplateRequest $signature_request_bulk_create_embedded_with_template_request, string $contentType = self::contentTypes['signatureRequestBulkCreateEmbeddedWithTemplate'][0]) { - return $this->signatureRequestBulkCreateEmbeddedWithTemplateAsyncWithHttpInfo($signature_request_bulk_create_embedded_with_template_request) + return $this->signatureRequestBulkCreateEmbeddedWithTemplateAsyncWithHttpInfo($signature_request_bulk_create_embedded_with_template_request, $contentType) ->then( function ($response) { return $response[0]; @@ -296,23 +362,28 @@ function ($response) { * Embedded Bulk Send with Template * * @param Model\SignatureRequestBulkCreateEmbeddedWithTemplateRequest $signature_request_bulk_create_embedded_with_template_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestBulkCreateEmbeddedWithTemplate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestBulkCreateEmbeddedWithTemplate. This method will eventually become unavailable */ - public function signatureRequestBulkCreateEmbeddedWithTemplateAsyncWithHttpInfo(Model\SignatureRequestBulkCreateEmbeddedWithTemplateRequest $signature_request_bulk_create_embedded_with_template_request) + public function signatureRequestBulkCreateEmbeddedWithTemplateAsyncWithHttpInfo(Model\SignatureRequestBulkCreateEmbeddedWithTemplateRequest $signature_request_bulk_create_embedded_with_template_request, string $contentType = self::contentTypes['signatureRequestBulkCreateEmbeddedWithTemplate'][0]) { $returnType = '\Dropbox\Sign\Model\BulkSendJobSendResponse'; - $request = $this->signatureRequestBulkCreateEmbeddedWithTemplateRequest($signature_request_bulk_create_embedded_with_template_request); + $request = $this->signatureRequestBulkCreateEmbeddedWithTemplateRequest($signature_request_bulk_create_embedded_with_template_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -332,7 +403,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -342,11 +413,13 @@ function ($exception) { * Create request for operation 'signatureRequestBulkCreateEmbeddedWithTemplate' * * @param Model\SignatureRequestBulkCreateEmbeddedWithTemplateRequest $signature_request_bulk_create_embedded_with_template_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestBulkCreateEmbeddedWithTemplate'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::signatureRequestBulkCreateEmbeddedWithTemplate. This method will eventually become unavailable */ - public function signatureRequestBulkCreateEmbeddedWithTemplateRequest(Model\SignatureRequestBulkCreateEmbeddedWithTemplateRequest $signature_request_bulk_create_embedded_with_template_request) + public function signatureRequestBulkCreateEmbeddedWithTemplateRequest(Model\SignatureRequestBulkCreateEmbeddedWithTemplateRequest $signature_request_bulk_create_embedded_with_template_request, string $contentType = self::contentTypes['signatureRequestBulkCreateEmbeddedWithTemplate'][0]) { // verify the required parameter 'signature_request_bulk_create_embedded_with_template_request' is set if ($signature_request_bulk_create_embedded_with_template_request === null || (is_array($signature_request_bulk_create_embedded_with_template_request) && count($signature_request_bulk_create_embedded_with_template_request) === 0)) { @@ -356,9 +429,11 @@ public function signatureRequestBulkCreateEmbeddedWithTemplateRequest(Model\Sign } $resourcePath = '/signature_request/bulk_create_embedded_with_template'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $signature_request_bulk_create_embedded_with_template_request @@ -366,21 +441,17 @@ public function signatureRequestBulkCreateEmbeddedWithTemplateRequest(Model\Sign $multipart = !empty($formParams); - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json', 'multipart/form-data'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($signature_request_bulk_create_embedded_with_template_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($signature_request_bulk_create_embedded_with_template_request)); } else { $httpBody = $signature_request_bulk_create_embedded_with_template_request; } @@ -399,22 +470,22 @@ public function signatureRequestBulkCreateEmbeddedWithTemplateRequest(Model\Sign // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $signature_request_bulk_create_embedded_with_template_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -434,11 +505,11 @@ public function signatureRequestBulkCreateEmbeddedWithTemplateRequest(Model\Sign $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -451,14 +522,13 @@ public function signatureRequestBulkCreateEmbeddedWithTemplateRequest(Model\Sign * * @param Model\SignatureRequestBulkSendWithTemplateRequest $signature_request_bulk_send_with_template_request signature_request_bulk_send_with_template_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\BulkSendJobSendResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function signatureRequestBulkSendWithTemplate(Model\SignatureRequestBulkSendWithTemplateRequest $signature_request_bulk_send_with_template_request) { list($response) = $this->signatureRequestBulkSendWithTemplateWithHttpInfo($signature_request_bulk_send_with_template_request); - return $response; } @@ -468,14 +538,16 @@ public function signatureRequestBulkSendWithTemplate(Model\SignatureRequestBulkS * Bulk Send with Template * * @param Model\SignatureRequestBulkSendWithTemplateRequest $signature_request_bulk_send_with_template_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestBulkSendWithTemplate'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\BulkSendJobSendResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::signatureRequestBulkSendWithTemplate. This method will eventually become unavailable */ - public function signatureRequestBulkSendWithTemplateWithHttpInfo(Model\SignatureRequestBulkSendWithTemplateRequest $signature_request_bulk_send_with_template_request) + public function signatureRequestBulkSendWithTemplateWithHttpInfo(Model\SignatureRequestBulkSendWithTemplateRequest $signature_request_bulk_send_with_template_request, string $contentType = self::contentTypes['signatureRequestBulkSendWithTemplate'][0]) { - $request = $this->signatureRequestBulkSendWithTemplateRequest($signature_request_bulk_send_with_template_request); + $request = $this->signatureRequestBulkSendWithTemplateRequest($signature_request_bulk_send_with_template_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -485,14 +557,14 @@ public function signatureRequestBulkSendWithTemplateWithHttpInfo(Model\Signature } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -505,51 +577,73 @@ public function signatureRequestBulkSendWithTemplateWithHttpInfo(Model\Signature sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\BulkSendJobSendResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\BulkSendJobSendResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\BulkSendJobSendResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\BulkSendJobSendResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\BulkSendJobSendResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\BulkSendJobSendResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -558,28 +652,19 @@ public function signatureRequestBulkSendWithTemplateWithHttpInfo(Model\Signature $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\BulkSendJobSendResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\BulkSendJobSendResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -590,13 +675,15 @@ public function signatureRequestBulkSendWithTemplateWithHttpInfo(Model\Signature * Bulk Send with Template * * @param Model\SignatureRequestBulkSendWithTemplateRequest $signature_request_bulk_send_with_template_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestBulkSendWithTemplate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestBulkSendWithTemplate. This method will eventually become unavailable */ - public function signatureRequestBulkSendWithTemplateAsync(Model\SignatureRequestBulkSendWithTemplateRequest $signature_request_bulk_send_with_template_request) + public function signatureRequestBulkSendWithTemplateAsync(Model\SignatureRequestBulkSendWithTemplateRequest $signature_request_bulk_send_with_template_request, string $contentType = self::contentTypes['signatureRequestBulkSendWithTemplate'][0]) { - return $this->signatureRequestBulkSendWithTemplateAsyncWithHttpInfo($signature_request_bulk_send_with_template_request) + return $this->signatureRequestBulkSendWithTemplateAsyncWithHttpInfo($signature_request_bulk_send_with_template_request, $contentType) ->then( function ($response) { return $response[0]; @@ -610,23 +697,28 @@ function ($response) { * Bulk Send with Template * * @param Model\SignatureRequestBulkSendWithTemplateRequest $signature_request_bulk_send_with_template_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestBulkSendWithTemplate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestBulkSendWithTemplate. This method will eventually become unavailable */ - public function signatureRequestBulkSendWithTemplateAsyncWithHttpInfo(Model\SignatureRequestBulkSendWithTemplateRequest $signature_request_bulk_send_with_template_request) + public function signatureRequestBulkSendWithTemplateAsyncWithHttpInfo(Model\SignatureRequestBulkSendWithTemplateRequest $signature_request_bulk_send_with_template_request, string $contentType = self::contentTypes['signatureRequestBulkSendWithTemplate'][0]) { $returnType = '\Dropbox\Sign\Model\BulkSendJobSendResponse'; - $request = $this->signatureRequestBulkSendWithTemplateRequest($signature_request_bulk_send_with_template_request); + $request = $this->signatureRequestBulkSendWithTemplateRequest($signature_request_bulk_send_with_template_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -646,7 +738,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -656,11 +748,13 @@ function ($exception) { * Create request for operation 'signatureRequestBulkSendWithTemplate' * * @param Model\SignatureRequestBulkSendWithTemplateRequest $signature_request_bulk_send_with_template_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestBulkSendWithTemplate'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::signatureRequestBulkSendWithTemplate. This method will eventually become unavailable */ - public function signatureRequestBulkSendWithTemplateRequest(Model\SignatureRequestBulkSendWithTemplateRequest $signature_request_bulk_send_with_template_request) + public function signatureRequestBulkSendWithTemplateRequest(Model\SignatureRequestBulkSendWithTemplateRequest $signature_request_bulk_send_with_template_request, string $contentType = self::contentTypes['signatureRequestBulkSendWithTemplate'][0]) { // verify the required parameter 'signature_request_bulk_send_with_template_request' is set if ($signature_request_bulk_send_with_template_request === null || (is_array($signature_request_bulk_send_with_template_request) && count($signature_request_bulk_send_with_template_request) === 0)) { @@ -670,9 +764,11 @@ public function signatureRequestBulkSendWithTemplateRequest(Model\SignatureReque } $resourcePath = '/signature_request/bulk_send_with_template'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $signature_request_bulk_send_with_template_request @@ -680,21 +776,17 @@ public function signatureRequestBulkSendWithTemplateRequest(Model\SignatureReque $multipart = !empty($formParams); - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json', 'multipart/form-data'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($signature_request_bulk_send_with_template_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($signature_request_bulk_send_with_template_request)); } else { $httpBody = $signature_request_bulk_send_with_template_request; } @@ -713,22 +805,22 @@ public function signatureRequestBulkSendWithTemplateRequest(Model\SignatureReque // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $signature_request_bulk_send_with_template_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -752,11 +844,11 @@ public function signatureRequestBulkSendWithTemplateRequest(Model\SignatureReque $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -769,9 +861,8 @@ public function signatureRequestBulkSendWithTemplateRequest(Model\SignatureReque * * @param string $signature_request_id The id of the incomplete SignatureRequest to cancel. (required) * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException - * @return void */ public function signatureRequestCancel(string $signature_request_id) { @@ -784,14 +875,16 @@ public function signatureRequestCancel(string $signature_request_id) * Cancel Incomplete Signature Request * * @param string $signature_request_id The id of the incomplete SignatureRequest to cancel. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestCancel'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::signatureRequestCancel. This method will eventually become unavailable */ - public function signatureRequestCancelWithHttpInfo(string $signature_request_id) + public function signatureRequestCancelWithHttpInfo(string $signature_request_id, string $contentType = self::contentTypes['signatureRequestCancel'][0]) { - $request = $this->signatureRequestCancelRequest($signature_request_id); + $request = $this->signatureRequestCancelRequest($signature_request_id, $contentType); try { $options = $this->createHttpClientOption(); @@ -801,14 +894,14 @@ public function signatureRequestCancelWithHttpInfo(string $signature_request_id) } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -821,29 +914,21 @@ public function signatureRequestCancelWithHttpInfo(string $signature_request_id) sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } return [null, $statusCode, $response->getHeaders()]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { } - throw $e; } } @@ -854,13 +939,15 @@ public function signatureRequestCancelWithHttpInfo(string $signature_request_id) * Cancel Incomplete Signature Request * * @param string $signature_request_id The id of the incomplete SignatureRequest to cancel. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestCancel'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestCancel. This method will eventually become unavailable */ - public function signatureRequestCancelAsync(string $signature_request_id) + public function signatureRequestCancelAsync(string $signature_request_id, string $contentType = self::contentTypes['signatureRequestCancel'][0]) { - return $this->signatureRequestCancelAsyncWithHttpInfo($signature_request_id) + return $this->signatureRequestCancelAsyncWithHttpInfo($signature_request_id, $contentType) ->then( function ($response) { return $response[0]; @@ -874,14 +961,16 @@ function ($response) { * Cancel Incomplete Signature Request * * @param string $signature_request_id The id of the incomplete SignatureRequest to cancel. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestCancel'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestCancel. This method will eventually become unavailable */ - public function signatureRequestCancelAsyncWithHttpInfo(string $signature_request_id) + public function signatureRequestCancelAsyncWithHttpInfo(string $signature_request_id, string $contentType = self::contentTypes['signatureRequestCancel'][0]) { $returnType = ''; - $request = $this->signatureRequestCancelRequest($signature_request_id); + $request = $this->signatureRequestCancelRequest($signature_request_id, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -900,7 +989,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -910,11 +999,13 @@ function ($exception) { * Create request for operation 'signatureRequestCancel' * * @param string $signature_request_id The id of the incomplete SignatureRequest to cancel. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestCancel'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::signatureRequestCancel. This method will eventually become unavailable */ - public function signatureRequestCancelRequest(string $signature_request_id) + public function signatureRequestCancelRequest(string $signature_request_id, string $contentType = self::contentTypes['signatureRequestCancel'][0]) { // verify the required parameter 'signature_request_id' is set if ($signature_request_id === null || (is_array($signature_request_id) && count($signature_request_id) === 0)) { @@ -924,32 +1015,26 @@ public function signatureRequestCancelRequest(string $signature_request_id) } $resourcePath = '/signature_request/cancel/{signature_request_id}'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // path params if ($signature_request_id !== null) { $resourcePath = str_replace( - '{' . 'signature_request_id' . '}', + '{signature_request_id}', ObjectSerializer::toPathValue($signature_request_id), $resourcePath ); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -967,18 +1052,19 @@ public function signatureRequestCancelRequest(string $signature_request_id) // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -1002,11 +1088,11 @@ public function signatureRequestCancelRequest(string $signature_request_id) $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1019,14 +1105,13 @@ public function signatureRequestCancelRequest(string $signature_request_id) * * @param Model\SignatureRequestCreateEmbeddedRequest $signature_request_create_embedded_request signature_request_create_embedded_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\SignatureRequestGetResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function signatureRequestCreateEmbedded(Model\SignatureRequestCreateEmbeddedRequest $signature_request_create_embedded_request) { list($response) = $this->signatureRequestCreateEmbeddedWithHttpInfo($signature_request_create_embedded_request); - return $response; } @@ -1036,14 +1121,16 @@ public function signatureRequestCreateEmbedded(Model\SignatureRequestCreateEmbed * Create Embedded Signature Request * * @param Model\SignatureRequestCreateEmbeddedRequest $signature_request_create_embedded_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestCreateEmbedded'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\SignatureRequestGetResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::signatureRequestCreateEmbedded. This method will eventually become unavailable */ - public function signatureRequestCreateEmbeddedWithHttpInfo(Model\SignatureRequestCreateEmbeddedRequest $signature_request_create_embedded_request) + public function signatureRequestCreateEmbeddedWithHttpInfo(Model\SignatureRequestCreateEmbeddedRequest $signature_request_create_embedded_request, string $contentType = self::contentTypes['signatureRequestCreateEmbedded'][0]) { - $request = $this->signatureRequestCreateEmbeddedRequest($signature_request_create_embedded_request); + $request = $this->signatureRequestCreateEmbeddedRequest($signature_request_create_embedded_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -1053,14 +1140,14 @@ public function signatureRequestCreateEmbeddedWithHttpInfo(Model\SignatureReques } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -1073,51 +1160,73 @@ public function signatureRequestCreateEmbeddedWithHttpInfo(Model\SignatureReques sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\SignatureRequestGetResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\SignatureRequestGetResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\SignatureRequestGetResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\SignatureRequestGetResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\SignatureRequestGetResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\SignatureRequestGetResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -1126,28 +1235,19 @@ public function signatureRequestCreateEmbeddedWithHttpInfo(Model\SignatureReques $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\SignatureRequestGetResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\SignatureRequestGetResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -1158,13 +1258,15 @@ public function signatureRequestCreateEmbeddedWithHttpInfo(Model\SignatureReques * Create Embedded Signature Request * * @param Model\SignatureRequestCreateEmbeddedRequest $signature_request_create_embedded_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestCreateEmbedded'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestCreateEmbedded. This method will eventually become unavailable */ - public function signatureRequestCreateEmbeddedAsync(Model\SignatureRequestCreateEmbeddedRequest $signature_request_create_embedded_request) + public function signatureRequestCreateEmbeddedAsync(Model\SignatureRequestCreateEmbeddedRequest $signature_request_create_embedded_request, string $contentType = self::contentTypes['signatureRequestCreateEmbedded'][0]) { - return $this->signatureRequestCreateEmbeddedAsyncWithHttpInfo($signature_request_create_embedded_request) + return $this->signatureRequestCreateEmbeddedAsyncWithHttpInfo($signature_request_create_embedded_request, $contentType) ->then( function ($response) { return $response[0]; @@ -1178,23 +1280,28 @@ function ($response) { * Create Embedded Signature Request * * @param Model\SignatureRequestCreateEmbeddedRequest $signature_request_create_embedded_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestCreateEmbedded'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestCreateEmbedded. This method will eventually become unavailable */ - public function signatureRequestCreateEmbeddedAsyncWithHttpInfo(Model\SignatureRequestCreateEmbeddedRequest $signature_request_create_embedded_request) + public function signatureRequestCreateEmbeddedAsyncWithHttpInfo(Model\SignatureRequestCreateEmbeddedRequest $signature_request_create_embedded_request, string $contentType = self::contentTypes['signatureRequestCreateEmbedded'][0]) { $returnType = '\Dropbox\Sign\Model\SignatureRequestGetResponse'; - $request = $this->signatureRequestCreateEmbeddedRequest($signature_request_create_embedded_request); + $request = $this->signatureRequestCreateEmbeddedRequest($signature_request_create_embedded_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -1214,7 +1321,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -1224,11 +1331,13 @@ function ($exception) { * Create request for operation 'signatureRequestCreateEmbedded' * * @param Model\SignatureRequestCreateEmbeddedRequest $signature_request_create_embedded_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestCreateEmbedded'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::signatureRequestCreateEmbedded. This method will eventually become unavailable */ - public function signatureRequestCreateEmbeddedRequest(Model\SignatureRequestCreateEmbeddedRequest $signature_request_create_embedded_request) + public function signatureRequestCreateEmbeddedRequest(Model\SignatureRequestCreateEmbeddedRequest $signature_request_create_embedded_request, string $contentType = self::contentTypes['signatureRequestCreateEmbedded'][0]) { // verify the required parameter 'signature_request_create_embedded_request' is set if ($signature_request_create_embedded_request === null || (is_array($signature_request_create_embedded_request) && count($signature_request_create_embedded_request) === 0)) { @@ -1238,9 +1347,11 @@ public function signatureRequestCreateEmbeddedRequest(Model\SignatureRequestCrea } $resourcePath = '/signature_request/create_embedded'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $signature_request_create_embedded_request @@ -1248,21 +1359,17 @@ public function signatureRequestCreateEmbeddedRequest(Model\SignatureRequestCrea $multipart = !empty($formParams); - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json', 'multipart/form-data'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($signature_request_create_embedded_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($signature_request_create_embedded_request)); } else { $httpBody = $signature_request_create_embedded_request; } @@ -1281,22 +1388,22 @@ public function signatureRequestCreateEmbeddedRequest(Model\SignatureRequestCrea // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $signature_request_create_embedded_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -1320,11 +1427,11 @@ public function signatureRequestCreateEmbeddedRequest(Model\SignatureRequestCrea $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1337,14 +1444,13 @@ public function signatureRequestCreateEmbeddedRequest(Model\SignatureRequestCrea * * @param Model\SignatureRequestCreateEmbeddedWithTemplateRequest $signature_request_create_embedded_with_template_request signature_request_create_embedded_with_template_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\SignatureRequestGetResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function signatureRequestCreateEmbeddedWithTemplate(Model\SignatureRequestCreateEmbeddedWithTemplateRequest $signature_request_create_embedded_with_template_request) { list($response) = $this->signatureRequestCreateEmbeddedWithTemplateWithHttpInfo($signature_request_create_embedded_with_template_request); - return $response; } @@ -1354,14 +1460,16 @@ public function signatureRequestCreateEmbeddedWithTemplate(Model\SignatureReques * Create Embedded Signature Request with Template * * @param Model\SignatureRequestCreateEmbeddedWithTemplateRequest $signature_request_create_embedded_with_template_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestCreateEmbeddedWithTemplate'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\SignatureRequestGetResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::signatureRequestCreateEmbeddedWithTemplate. This method will eventually become unavailable */ - public function signatureRequestCreateEmbeddedWithTemplateWithHttpInfo(Model\SignatureRequestCreateEmbeddedWithTemplateRequest $signature_request_create_embedded_with_template_request) + public function signatureRequestCreateEmbeddedWithTemplateWithHttpInfo(Model\SignatureRequestCreateEmbeddedWithTemplateRequest $signature_request_create_embedded_with_template_request, string $contentType = self::contentTypes['signatureRequestCreateEmbeddedWithTemplate'][0]) { - $request = $this->signatureRequestCreateEmbeddedWithTemplateRequest($signature_request_create_embedded_with_template_request); + $request = $this->signatureRequestCreateEmbeddedWithTemplateRequest($signature_request_create_embedded_with_template_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -1371,14 +1479,14 @@ public function signatureRequestCreateEmbeddedWithTemplateWithHttpInfo(Model\Sig } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -1391,51 +1499,73 @@ public function signatureRequestCreateEmbeddedWithTemplateWithHttpInfo(Model\Sig sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\SignatureRequestGetResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\SignatureRequestGetResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\SignatureRequestGetResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\SignatureRequestGetResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\SignatureRequestGetResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\SignatureRequestGetResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -1444,28 +1574,19 @@ public function signatureRequestCreateEmbeddedWithTemplateWithHttpInfo(Model\Sig $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\SignatureRequestGetResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\SignatureRequestGetResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -1476,13 +1597,15 @@ public function signatureRequestCreateEmbeddedWithTemplateWithHttpInfo(Model\Sig * Create Embedded Signature Request with Template * * @param Model\SignatureRequestCreateEmbeddedWithTemplateRequest $signature_request_create_embedded_with_template_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestCreateEmbeddedWithTemplate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestCreateEmbeddedWithTemplate. This method will eventually become unavailable */ - public function signatureRequestCreateEmbeddedWithTemplateAsync(Model\SignatureRequestCreateEmbeddedWithTemplateRequest $signature_request_create_embedded_with_template_request) + public function signatureRequestCreateEmbeddedWithTemplateAsync(Model\SignatureRequestCreateEmbeddedWithTemplateRequest $signature_request_create_embedded_with_template_request, string $contentType = self::contentTypes['signatureRequestCreateEmbeddedWithTemplate'][0]) { - return $this->signatureRequestCreateEmbeddedWithTemplateAsyncWithHttpInfo($signature_request_create_embedded_with_template_request) + return $this->signatureRequestCreateEmbeddedWithTemplateAsyncWithHttpInfo($signature_request_create_embedded_with_template_request, $contentType) ->then( function ($response) { return $response[0]; @@ -1496,23 +1619,28 @@ function ($response) { * Create Embedded Signature Request with Template * * @param Model\SignatureRequestCreateEmbeddedWithTemplateRequest $signature_request_create_embedded_with_template_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestCreateEmbeddedWithTemplate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestCreateEmbeddedWithTemplate. This method will eventually become unavailable */ - public function signatureRequestCreateEmbeddedWithTemplateAsyncWithHttpInfo(Model\SignatureRequestCreateEmbeddedWithTemplateRequest $signature_request_create_embedded_with_template_request) + public function signatureRequestCreateEmbeddedWithTemplateAsyncWithHttpInfo(Model\SignatureRequestCreateEmbeddedWithTemplateRequest $signature_request_create_embedded_with_template_request, string $contentType = self::contentTypes['signatureRequestCreateEmbeddedWithTemplate'][0]) { $returnType = '\Dropbox\Sign\Model\SignatureRequestGetResponse'; - $request = $this->signatureRequestCreateEmbeddedWithTemplateRequest($signature_request_create_embedded_with_template_request); + $request = $this->signatureRequestCreateEmbeddedWithTemplateRequest($signature_request_create_embedded_with_template_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -1532,7 +1660,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -1542,11 +1670,13 @@ function ($exception) { * Create request for operation 'signatureRequestCreateEmbeddedWithTemplate' * * @param Model\SignatureRequestCreateEmbeddedWithTemplateRequest $signature_request_create_embedded_with_template_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestCreateEmbeddedWithTemplate'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::signatureRequestCreateEmbeddedWithTemplate. This method will eventually become unavailable */ - public function signatureRequestCreateEmbeddedWithTemplateRequest(Model\SignatureRequestCreateEmbeddedWithTemplateRequest $signature_request_create_embedded_with_template_request) + public function signatureRequestCreateEmbeddedWithTemplateRequest(Model\SignatureRequestCreateEmbeddedWithTemplateRequest $signature_request_create_embedded_with_template_request, string $contentType = self::contentTypes['signatureRequestCreateEmbeddedWithTemplate'][0]) { // verify the required parameter 'signature_request_create_embedded_with_template_request' is set if ($signature_request_create_embedded_with_template_request === null || (is_array($signature_request_create_embedded_with_template_request) && count($signature_request_create_embedded_with_template_request) === 0)) { @@ -1556,9 +1686,11 @@ public function signatureRequestCreateEmbeddedWithTemplateRequest(Model\Signatur } $resourcePath = '/signature_request/create_embedded_with_template'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $signature_request_create_embedded_with_template_request @@ -1566,21 +1698,17 @@ public function signatureRequestCreateEmbeddedWithTemplateRequest(Model\Signatur $multipart = !empty($formParams); - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json', 'multipart/form-data'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($signature_request_create_embedded_with_template_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($signature_request_create_embedded_with_template_request)); } else { $httpBody = $signature_request_create_embedded_with_template_request; } @@ -1599,22 +1727,22 @@ public function signatureRequestCreateEmbeddedWithTemplateRequest(Model\Signatur // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $signature_request_create_embedded_with_template_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -1638,11 +1766,11 @@ public function signatureRequestCreateEmbeddedWithTemplateRequest(Model\Signatur $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1654,16 +1782,15 @@ public function signatureRequestCreateEmbeddedWithTemplateRequest(Model\Signatur * Download Files * * @param string $signature_request_id The id of the SignatureRequest to retrieve. (required) - * @param string $file_type Set to `pdf` for a single merged document or `zip` for a collection of individual documents. (optional, default to 'pdf') + * @param string $file_type Set to `pdf` for a single merged document or `zip` for a collection of individual documents. (optional, default to 'pdf') * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return SplFileObject + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function signatureRequestFiles(string $signature_request_id, string $file_type = 'pdf') { list($response) = $this->signatureRequestFilesWithHttpInfo($signature_request_id, $file_type); - return $response; } @@ -1673,15 +1800,17 @@ public function signatureRequestFiles(string $signature_request_id, string $file * Download Files * * @param string $signature_request_id The id of the SignatureRequest to retrieve. (required) - * @param string $file_type Set to `pdf` for a single merged document or `zip` for a collection of individual documents. (optional, default to 'pdf') + * @param string $file_type Set to `pdf` for a single merged document or `zip` for a collection of individual documents. (optional, default to 'pdf') + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestFiles'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of \SplFileObject|\Dropbox\Sign\Model\ErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::signatureRequestFiles. This method will eventually become unavailable */ - public function signatureRequestFilesWithHttpInfo(string $signature_request_id, string $file_type = 'pdf') + public function signatureRequestFilesWithHttpInfo(string $signature_request_id, string $file_type = 'pdf', string $contentType = self::contentTypes['signatureRequestFiles'][0]) { - $request = $this->signatureRequestFilesRequest($signature_request_id, $file_type); + $request = $this->signatureRequestFilesRequest($signature_request_id, $file_type, $contentType); try { $options = $this->createHttpClientOption(); @@ -1691,14 +1820,14 @@ public function signatureRequestFilesWithHttpInfo(string $signature_request_id, } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -1711,51 +1840,73 @@ public function signatureRequestFilesWithHttpInfo(string $signature_request_id, sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\SplFileObject' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\SplFileObject', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\SplFileObject'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -1764,28 +1915,19 @@ public function signatureRequestFilesWithHttpInfo(string $signature_request_id, $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SplFileObject', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -1796,14 +1938,16 @@ public function signatureRequestFilesWithHttpInfo(string $signature_request_id, * Download Files * * @param string $signature_request_id The id of the SignatureRequest to retrieve. (required) - * @param string $file_type Set to `pdf` for a single merged document or `zip` for a collection of individual documents. (optional, default to 'pdf') + * @param string $file_type Set to `pdf` for a single merged document or `zip` for a collection of individual documents. (optional, default to 'pdf') + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestFiles'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestFiles. This method will eventually become unavailable */ - public function signatureRequestFilesAsync(string $signature_request_id, string $file_type = 'pdf') + public function signatureRequestFilesAsync(string $signature_request_id, string $file_type = 'pdf', string $contentType = self::contentTypes['signatureRequestFiles'][0]) { - return $this->signatureRequestFilesAsyncWithHttpInfo($signature_request_id, $file_type) + return $this->signatureRequestFilesAsyncWithHttpInfo($signature_request_id, $file_type, $contentType) ->then( function ($response) { return $response[0]; @@ -1817,24 +1961,29 @@ function ($response) { * Download Files * * @param string $signature_request_id The id of the SignatureRequest to retrieve. (required) - * @param string $file_type Set to `pdf` for a single merged document or `zip` for a collection of individual documents. (optional, default to 'pdf') + * @param string $file_type Set to `pdf` for a single merged document or `zip` for a collection of individual documents. (optional, default to 'pdf') + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestFiles'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestFiles. This method will eventually become unavailable */ - public function signatureRequestFilesAsyncWithHttpInfo(string $signature_request_id, string $file_type = 'pdf') + public function signatureRequestFilesAsyncWithHttpInfo(string $signature_request_id, string $file_type = 'pdf', string $contentType = self::contentTypes['signatureRequestFiles'][0]) { $returnType = '\SplFileObject'; - $request = $this->signatureRequestFilesRequest($signature_request_id, $file_type); + $request = $this->signatureRequestFilesRequest($signature_request_id, $file_type, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -1854,7 +2003,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -1864,12 +2013,14 @@ function ($exception) { * Create request for operation 'signatureRequestFiles' * * @param string $signature_request_id The id of the SignatureRequest to retrieve. (required) - * @param string $file_type Set to `pdf` for a single merged document or `zip` for a collection of individual documents. (optional, default to 'pdf') + * @param string $file_type Set to `pdf` for a single merged document or `zip` for a collection of individual documents. (optional, default to 'pdf') + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestFiles'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::signatureRequestFiles. This method will eventually become unavailable */ - public function signatureRequestFilesRequest(string $signature_request_id, string $file_type = 'pdf') + public function signatureRequestFilesRequest(string $signature_request_id, string $file_type = 'pdf', string $contentType = self::contentTypes['signatureRequestFiles'][0]) { // verify the required parameter 'signature_request_id' is set if ($signature_request_id === null || (is_array($signature_request_id) && count($signature_request_id) === 0)) { @@ -1879,43 +2030,36 @@ public function signatureRequestFilesRequest(string $signature_request_id, strin } $resourcePath = '/signature_request/files/{signature_request_id}'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // query params - if ($file_type !== null) { - if ('form' === 'form' && is_array($file_type)) { - foreach ($file_type as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['file_type'] = $file_type; - } - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $file_type, + 'file_type', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); // path params if ($signature_request_id !== null) { $resourcePath = str_replace( - '{' . 'signature_request_id' . '}', + '{signature_request_id}', ObjectSerializer::toPathValue($signature_request_id), $resourcePath ); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/pdf', 'application/zip', 'application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/pdf', 'application/zip', 'application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -1933,18 +2077,19 @@ public function signatureRequestFilesRequest(string $signature_request_id, strin // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -1968,11 +2113,11 @@ public function signatureRequestFilesRequest(string $signature_request_id, strin $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'GET', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1985,14 +2130,13 @@ public function signatureRequestFilesRequest(string $signature_request_id, strin * * @param string $signature_request_id The id of the SignatureRequest to retrieve. (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\FileResponseDataUri + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function signatureRequestFilesAsDataUri(string $signature_request_id) { list($response) = $this->signatureRequestFilesAsDataUriWithHttpInfo($signature_request_id); - return $response; } @@ -2002,14 +2146,16 @@ public function signatureRequestFilesAsDataUri(string $signature_request_id) * Download Files as Data Uri * * @param string $signature_request_id The id of the SignatureRequest to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestFilesAsDataUri'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\FileResponseDataUri, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::signatureRequestFilesAsDataUri. This method will eventually become unavailable */ - public function signatureRequestFilesAsDataUriWithHttpInfo(string $signature_request_id) + public function signatureRequestFilesAsDataUriWithHttpInfo(string $signature_request_id, string $contentType = self::contentTypes['signatureRequestFilesAsDataUri'][0]) { - $request = $this->signatureRequestFilesAsDataUriRequest($signature_request_id); + $request = $this->signatureRequestFilesAsDataUriRequest($signature_request_id, $contentType); try { $options = $this->createHttpClientOption(); @@ -2019,14 +2165,14 @@ public function signatureRequestFilesAsDataUriWithHttpInfo(string $signature_req } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -2039,51 +2185,73 @@ public function signatureRequestFilesAsDataUriWithHttpInfo(string $signature_req sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\FileResponseDataUri' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\FileResponseDataUri', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\FileResponseDataUri' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\FileResponseDataUri' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\FileResponseDataUri', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\FileResponseDataUri'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -2092,28 +2260,19 @@ public function signatureRequestFilesAsDataUriWithHttpInfo(string $signature_req $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\FileResponseDataUri', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\FileResponseDataUri', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -2124,13 +2283,15 @@ public function signatureRequestFilesAsDataUriWithHttpInfo(string $signature_req * Download Files as Data Uri * * @param string $signature_request_id The id of the SignatureRequest to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestFilesAsDataUri'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestFilesAsDataUri. This method will eventually become unavailable */ - public function signatureRequestFilesAsDataUriAsync(string $signature_request_id) + public function signatureRequestFilesAsDataUriAsync(string $signature_request_id, string $contentType = self::contentTypes['signatureRequestFilesAsDataUri'][0]) { - return $this->signatureRequestFilesAsDataUriAsyncWithHttpInfo($signature_request_id) + return $this->signatureRequestFilesAsDataUriAsyncWithHttpInfo($signature_request_id, $contentType) ->then( function ($response) { return $response[0]; @@ -2144,23 +2305,28 @@ function ($response) { * Download Files as Data Uri * * @param string $signature_request_id The id of the SignatureRequest to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestFilesAsDataUri'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestFilesAsDataUri. This method will eventually become unavailable */ - public function signatureRequestFilesAsDataUriAsyncWithHttpInfo(string $signature_request_id) + public function signatureRequestFilesAsDataUriAsyncWithHttpInfo(string $signature_request_id, string $contentType = self::contentTypes['signatureRequestFilesAsDataUri'][0]) { $returnType = '\Dropbox\Sign\Model\FileResponseDataUri'; - $request = $this->signatureRequestFilesAsDataUriRequest($signature_request_id); + $request = $this->signatureRequestFilesAsDataUriRequest($signature_request_id, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -2180,7 +2346,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -2190,11 +2356,13 @@ function ($exception) { * Create request for operation 'signatureRequestFilesAsDataUri' * * @param string $signature_request_id The id of the SignatureRequest to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestFilesAsDataUri'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::signatureRequestFilesAsDataUri. This method will eventually become unavailable */ - public function signatureRequestFilesAsDataUriRequest(string $signature_request_id) + public function signatureRequestFilesAsDataUriRequest(string $signature_request_id, string $contentType = self::contentTypes['signatureRequestFilesAsDataUri'][0]) { // verify the required parameter 'signature_request_id' is set if ($signature_request_id === null || (is_array($signature_request_id) && count($signature_request_id) === 0)) { @@ -2204,32 +2372,26 @@ public function signatureRequestFilesAsDataUriRequest(string $signature_request_ } $resourcePath = '/signature_request/files_as_data_uri/{signature_request_id}'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // path params if ($signature_request_id !== null) { $resourcePath = str_replace( - '{' . 'signature_request_id' . '}', + '{signature_request_id}', ObjectSerializer::toPathValue($signature_request_id), $resourcePath ); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -2247,18 +2409,19 @@ public function signatureRequestFilesAsDataUriRequest(string $signature_request_ // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -2282,11 +2445,11 @@ public function signatureRequestFilesAsDataUriRequest(string $signature_request_ $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'GET', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -2298,16 +2461,15 @@ public function signatureRequestFilesAsDataUriRequest(string $signature_request_ * Download Files as File Url * * @param string $signature_request_id The id of the SignatureRequest to retrieve. (required) - * @param int $force_download By default when opening the `file_url` a browser will download the PDF and save it locally. When set to `0` the PDF file will be displayed in the browser. (optional, default to 1) + * @param int $force_download By default when opening the `file_url` a browser will download the PDF and save it locally. When set to `0` the PDF file will be displayed in the browser. (optional, default to 1) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\FileResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function signatureRequestFilesAsFileUrl(string $signature_request_id, int $force_download = 1) { list($response) = $this->signatureRequestFilesAsFileUrlWithHttpInfo($signature_request_id, $force_download); - return $response; } @@ -2317,15 +2479,17 @@ public function signatureRequestFilesAsFileUrl(string $signature_request_id, int * Download Files as File Url * * @param string $signature_request_id The id of the SignatureRequest to retrieve. (required) - * @param int $force_download By default when opening the `file_url` a browser will download the PDF and save it locally. When set to `0` the PDF file will be displayed in the browser. (optional, default to 1) + * @param int $force_download By default when opening the `file_url` a browser will download the PDF and save it locally. When set to `0` the PDF file will be displayed in the browser. (optional, default to 1) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestFilesAsFileUrl'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\FileResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::signatureRequestFilesAsFileUrl. This method will eventually become unavailable */ - public function signatureRequestFilesAsFileUrlWithHttpInfo(string $signature_request_id, int $force_download = 1) + public function signatureRequestFilesAsFileUrlWithHttpInfo(string $signature_request_id, int $force_download = 1, string $contentType = self::contentTypes['signatureRequestFilesAsFileUrl'][0]) { - $request = $this->signatureRequestFilesAsFileUrlRequest($signature_request_id, $force_download); + $request = $this->signatureRequestFilesAsFileUrlRequest($signature_request_id, $force_download, $contentType); try { $options = $this->createHttpClientOption(); @@ -2335,14 +2499,14 @@ public function signatureRequestFilesAsFileUrlWithHttpInfo(string $signature_req } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -2355,51 +2519,73 @@ public function signatureRequestFilesAsFileUrlWithHttpInfo(string $signature_req sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\FileResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\FileResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\FileResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\FileResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\FileResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\FileResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -2408,28 +2594,19 @@ public function signatureRequestFilesAsFileUrlWithHttpInfo(string $signature_req $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\FileResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\FileResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -2440,14 +2617,16 @@ public function signatureRequestFilesAsFileUrlWithHttpInfo(string $signature_req * Download Files as File Url * * @param string $signature_request_id The id of the SignatureRequest to retrieve. (required) - * @param int $force_download By default when opening the `file_url` a browser will download the PDF and save it locally. When set to `0` the PDF file will be displayed in the browser. (optional, default to 1) + * @param int $force_download By default when opening the `file_url` a browser will download the PDF and save it locally. When set to `0` the PDF file will be displayed in the browser. (optional, default to 1) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestFilesAsFileUrl'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestFilesAsFileUrl. This method will eventually become unavailable */ - public function signatureRequestFilesAsFileUrlAsync(string $signature_request_id, int $force_download = 1) + public function signatureRequestFilesAsFileUrlAsync(string $signature_request_id, int $force_download = 1, string $contentType = self::contentTypes['signatureRequestFilesAsFileUrl'][0]) { - return $this->signatureRequestFilesAsFileUrlAsyncWithHttpInfo($signature_request_id, $force_download) + return $this->signatureRequestFilesAsFileUrlAsyncWithHttpInfo($signature_request_id, $force_download, $contentType) ->then( function ($response) { return $response[0]; @@ -2461,24 +2640,29 @@ function ($response) { * Download Files as File Url * * @param string $signature_request_id The id of the SignatureRequest to retrieve. (required) - * @param int $force_download By default when opening the `file_url` a browser will download the PDF and save it locally. When set to `0` the PDF file will be displayed in the browser. (optional, default to 1) + * @param int $force_download By default when opening the `file_url` a browser will download the PDF and save it locally. When set to `0` the PDF file will be displayed in the browser. (optional, default to 1) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestFilesAsFileUrl'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestFilesAsFileUrl. This method will eventually become unavailable */ - public function signatureRequestFilesAsFileUrlAsyncWithHttpInfo(string $signature_request_id, int $force_download = 1) + public function signatureRequestFilesAsFileUrlAsyncWithHttpInfo(string $signature_request_id, int $force_download = 1, string $contentType = self::contentTypes['signatureRequestFilesAsFileUrl'][0]) { $returnType = '\Dropbox\Sign\Model\FileResponse'; - $request = $this->signatureRequestFilesAsFileUrlRequest($signature_request_id, $force_download); + $request = $this->signatureRequestFilesAsFileUrlRequest($signature_request_id, $force_download, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -2498,7 +2682,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -2508,12 +2692,14 @@ function ($exception) { * Create request for operation 'signatureRequestFilesAsFileUrl' * * @param string $signature_request_id The id of the SignatureRequest to retrieve. (required) - * @param int $force_download By default when opening the `file_url` a browser will download the PDF and save it locally. When set to `0` the PDF file will be displayed in the browser. (optional, default to 1) + * @param int $force_download By default when opening the `file_url` a browser will download the PDF and save it locally. When set to `0` the PDF file will be displayed in the browser. (optional, default to 1) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestFilesAsFileUrl'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::signatureRequestFilesAsFileUrl. This method will eventually become unavailable */ - public function signatureRequestFilesAsFileUrlRequest(string $signature_request_id, int $force_download = 1) + public function signatureRequestFilesAsFileUrlRequest(string $signature_request_id, int $force_download = 1, string $contentType = self::contentTypes['signatureRequestFilesAsFileUrl'][0]) { // verify the required parameter 'signature_request_id' is set if ($signature_request_id === null || (is_array($signature_request_id) && count($signature_request_id) === 0)) { @@ -2523,43 +2709,36 @@ public function signatureRequestFilesAsFileUrlRequest(string $signature_request_ } $resourcePath = '/signature_request/files_as_file_url/{signature_request_id}'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // query params - if ($force_download !== null) { - if ('form' === 'form' && is_array($force_download)) { - foreach ($force_download as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['force_download'] = $force_download; - } - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $force_download, + 'force_download', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); // path params if ($signature_request_id !== null) { $resourcePath = str_replace( - '{' . 'signature_request_id' . '}', + '{signature_request_id}', ObjectSerializer::toPathValue($signature_request_id), $resourcePath ); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -2577,18 +2756,19 @@ public function signatureRequestFilesAsFileUrlRequest(string $signature_request_ // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -2612,11 +2792,11 @@ public function signatureRequestFilesAsFileUrlRequest(string $signature_request_ $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'GET', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -2629,14 +2809,13 @@ public function signatureRequestFilesAsFileUrlRequest(string $signature_request_ * * @param string $signature_request_id The id of the SignatureRequest to retrieve. (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\SignatureRequestGetResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function signatureRequestGet(string $signature_request_id) { list($response) = $this->signatureRequestGetWithHttpInfo($signature_request_id); - return $response; } @@ -2646,14 +2825,16 @@ public function signatureRequestGet(string $signature_request_id) * Get Signature Request * * @param string $signature_request_id The id of the SignatureRequest to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestGet'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\SignatureRequestGetResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::signatureRequestGet. This method will eventually become unavailable */ - public function signatureRequestGetWithHttpInfo(string $signature_request_id) + public function signatureRequestGetWithHttpInfo(string $signature_request_id, string $contentType = self::contentTypes['signatureRequestGet'][0]) { - $request = $this->signatureRequestGetRequest($signature_request_id); + $request = $this->signatureRequestGetRequest($signature_request_id, $contentType); try { $options = $this->createHttpClientOption(); @@ -2663,14 +2844,14 @@ public function signatureRequestGetWithHttpInfo(string $signature_request_id) } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -2683,51 +2864,73 @@ public function signatureRequestGetWithHttpInfo(string $signature_request_id) sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\SignatureRequestGetResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\SignatureRequestGetResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\SignatureRequestGetResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\SignatureRequestGetResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\SignatureRequestGetResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\SignatureRequestGetResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -2736,28 +2939,19 @@ public function signatureRequestGetWithHttpInfo(string $signature_request_id) $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\SignatureRequestGetResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\SignatureRequestGetResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -2768,13 +2962,15 @@ public function signatureRequestGetWithHttpInfo(string $signature_request_id) * Get Signature Request * * @param string $signature_request_id The id of the SignatureRequest to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestGet'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestGet. This method will eventually become unavailable */ - public function signatureRequestGetAsync(string $signature_request_id) + public function signatureRequestGetAsync(string $signature_request_id, string $contentType = self::contentTypes['signatureRequestGet'][0]) { - return $this->signatureRequestGetAsyncWithHttpInfo($signature_request_id) + return $this->signatureRequestGetAsyncWithHttpInfo($signature_request_id, $contentType) ->then( function ($response) { return $response[0]; @@ -2788,23 +2984,28 @@ function ($response) { * Get Signature Request * * @param string $signature_request_id The id of the SignatureRequest to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestGet'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestGet. This method will eventually become unavailable */ - public function signatureRequestGetAsyncWithHttpInfo(string $signature_request_id) + public function signatureRequestGetAsyncWithHttpInfo(string $signature_request_id, string $contentType = self::contentTypes['signatureRequestGet'][0]) { $returnType = '\Dropbox\Sign\Model\SignatureRequestGetResponse'; - $request = $this->signatureRequestGetRequest($signature_request_id); + $request = $this->signatureRequestGetRequest($signature_request_id, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -2824,7 +3025,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -2834,11 +3035,13 @@ function ($exception) { * Create request for operation 'signatureRequestGet' * * @param string $signature_request_id The id of the SignatureRequest to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestGet'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::signatureRequestGet. This method will eventually become unavailable */ - public function signatureRequestGetRequest(string $signature_request_id) + public function signatureRequestGetRequest(string $signature_request_id, string $contentType = self::contentTypes['signatureRequestGet'][0]) { // verify the required parameter 'signature_request_id' is set if ($signature_request_id === null || (is_array($signature_request_id) && count($signature_request_id) === 0)) { @@ -2848,32 +3051,26 @@ public function signatureRequestGetRequest(string $signature_request_id) } $resourcePath = '/signature_request/{signature_request_id}'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // path params if ($signature_request_id !== null) { $resourcePath = str_replace( - '{' . 'signature_request_id' . '}', + '{signature_request_id}', ObjectSerializer::toPathValue($signature_request_id), $resourcePath ); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -2891,18 +3088,19 @@ public function signatureRequestGetRequest(string $signature_request_id) // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -2926,11 +3124,11 @@ public function signatureRequestGetRequest(string $signature_request_id) $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'GET', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -2942,18 +3140,17 @@ public function signatureRequestGetRequest(string $signature_request_id) * List Signature Requests * * @param string $account_id Which account to return SignatureRequests for. Must be a team member. Use `all` to indicate all team members. Defaults to your account. (optional) - * @param int $page Which page number of the SignatureRequest List to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) - * @param string $query String that includes search terms and/or fields to be used to filter the SignatureRequest objects. (optional) + * @param int $page Which page number of the SignatureRequest List to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $query String that includes search terms and/or fields to be used to filter the SignatureRequest objects. (optional) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\SignatureRequestListResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function signatureRequestList(string $account_id = null, int $page = 1, int $page_size = 20, string $query = null) { list($response) = $this->signatureRequestListWithHttpInfo($account_id, $page, $page_size, $query); - return $response; } @@ -2962,18 +3159,20 @@ public function signatureRequestList(string $account_id = null, int $page = 1, i * * List Signature Requests * - * @param string $account_id Which account to return SignatureRequests for. Must be a team member. Use `all` to indicate all team members. Defaults to your account. (optional) - * @param int $page Which page number of the SignatureRequest List to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) - * @param string $query String that includes search terms and/or fields to be used to filter the SignatureRequest objects. (optional) + * @param string $account_id Which account to return SignatureRequests for. Must be a team member. Use `all` to indicate all team members. Defaults to your account. (optional) + * @param int $page Which page number of the SignatureRequest List to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $query String that includes search terms and/or fields to be used to filter the SignatureRequest objects. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestList'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\SignatureRequestListResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::signatureRequestList. This method will eventually become unavailable */ - public function signatureRequestListWithHttpInfo(string $account_id = null, int $page = 1, int $page_size = 20, string $query = null) + public function signatureRequestListWithHttpInfo(string $account_id = null, int $page = 1, int $page_size = 20, string $query = null, string $contentType = self::contentTypes['signatureRequestList'][0]) { - $request = $this->signatureRequestListRequest($account_id, $page, $page_size, $query); + $request = $this->signatureRequestListRequest($account_id, $page, $page_size, $query, $contentType); try { $options = $this->createHttpClientOption(); @@ -2983,14 +3182,14 @@ public function signatureRequestListWithHttpInfo(string $account_id = null, int } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -3003,51 +3202,73 @@ public function signatureRequestListWithHttpInfo(string $account_id = null, int sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\SignatureRequestListResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\SignatureRequestListResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\SignatureRequestListResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\SignatureRequestListResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\SignatureRequestListResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\SignatureRequestListResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -3056,28 +3277,19 @@ public function signatureRequestListWithHttpInfo(string $account_id = null, int $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\SignatureRequestListResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\SignatureRequestListResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -3087,17 +3299,19 @@ public function signatureRequestListWithHttpInfo(string $account_id = null, int * * List Signature Requests * - * @param string $account_id Which account to return SignatureRequests for. Must be a team member. Use `all` to indicate all team members. Defaults to your account. (optional) - * @param int $page Which page number of the SignatureRequest List to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) - * @param string $query String that includes search terms and/or fields to be used to filter the SignatureRequest objects. (optional) + * @param string $account_id Which account to return SignatureRequests for. Must be a team member. Use `all` to indicate all team members. Defaults to your account. (optional) + * @param int $page Which page number of the SignatureRequest List to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $query String that includes search terms and/or fields to be used to filter the SignatureRequest objects. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestList'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestList. This method will eventually become unavailable */ - public function signatureRequestListAsync(string $account_id = null, int $page = 1, int $page_size = 20, string $query = null) + public function signatureRequestListAsync(string $account_id = null, int $page = 1, int $page_size = 20, string $query = null, string $contentType = self::contentTypes['signatureRequestList'][0]) { - return $this->signatureRequestListAsyncWithHttpInfo($account_id, $page, $page_size, $query) + return $this->signatureRequestListAsyncWithHttpInfo($account_id, $page, $page_size, $query, $contentType) ->then( function ($response) { return $response[0]; @@ -3110,27 +3324,32 @@ function ($response) { * * List Signature Requests * - * @param string $account_id Which account to return SignatureRequests for. Must be a team member. Use `all` to indicate all team members. Defaults to your account. (optional) - * @param int $page Which page number of the SignatureRequest List to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) - * @param string $query String that includes search terms and/or fields to be used to filter the SignatureRequest objects. (optional) + * @param string $account_id Which account to return SignatureRequests for. Must be a team member. Use `all` to indicate all team members. Defaults to your account. (optional) + * @param int $page Which page number of the SignatureRequest List to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $query String that includes search terms and/or fields to be used to filter the SignatureRequest objects. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestList'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestList. This method will eventually become unavailable */ - public function signatureRequestListAsyncWithHttpInfo(string $account_id = null, int $page = 1, int $page_size = 20, string $query = null) + public function signatureRequestListAsyncWithHttpInfo(string $account_id = null, int $page = 1, int $page_size = 20, string $query = null, string $contentType = self::contentTypes['signatureRequestList'][0]) { $returnType = '\Dropbox\Sign\Model\SignatureRequestListResponse'; - $request = $this->signatureRequestListRequest($account_id, $page, $page_size, $query); + $request = $this->signatureRequestListRequest($account_id, $page, $page_size, $query, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -3150,7 +3369,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -3159,75 +3378,67 @@ function ($exception) { /** * Create request for operation 'signatureRequestList' * - * @param string $account_id Which account to return SignatureRequests for. Must be a team member. Use `all` to indicate all team members. Defaults to your account. (optional) - * @param int $page Which page number of the SignatureRequest List to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) - * @param string $query String that includes search terms and/or fields to be used to filter the SignatureRequest objects. (optional) + * @param string $account_id Which account to return SignatureRequests for. Must be a team member. Use `all` to indicate all team members. Defaults to your account. (optional) + * @param int $page Which page number of the SignatureRequest List to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $query String that includes search terms and/or fields to be used to filter the SignatureRequest objects. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestList'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::signatureRequestList. This method will eventually become unavailable */ - public function signatureRequestListRequest(string $account_id = null, int $page = 1, int $page_size = 20, string $query = null) + public function signatureRequestListRequest(string $account_id = null, int $page = 1, int $page_size = 20, string $query = null, string $contentType = self::contentTypes['signatureRequestList'][0]) { $resourcePath = '/signature_request/list'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // query params - if ($account_id !== null) { - if ('form' === 'form' && is_array($account_id)) { - foreach ($account_id as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['account_id'] = $account_id; - } - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $account_id, + 'account_id', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); // query params - if ($page !== null) { - if ('form' === 'form' && is_array($page)) { - foreach ($page as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['page'] = $page; - } - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); // query params - if ($page_size !== null) { - if ('form' === 'form' && is_array($page_size)) { - foreach ($page_size as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['page_size'] = $page_size; - } - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'page_size', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); // query params - if ($query !== null) { - if ('form' === 'form' && is_array($query)) { - foreach ($query as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['query'] = $query; - } - } - - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $query, + 'query', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -3245,18 +3456,19 @@ public function signatureRequestListRequest(string $account_id = null, int $page // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -3280,11 +3492,11 @@ public function signatureRequestListRequest(string $account_id = null, int $page $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'GET', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -3297,14 +3509,13 @@ public function signatureRequestListRequest(string $account_id = null, int $page * * @param string $signature_request_id The id of the SignatureRequest to release. (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\SignatureRequestGetResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function signatureRequestReleaseHold(string $signature_request_id) { list($response) = $this->signatureRequestReleaseHoldWithHttpInfo($signature_request_id); - return $response; } @@ -3314,14 +3525,16 @@ public function signatureRequestReleaseHold(string $signature_request_id) * Release On-Hold Signature Request * * @param string $signature_request_id The id of the SignatureRequest to release. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestReleaseHold'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\SignatureRequestGetResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::signatureRequestReleaseHold. This method will eventually become unavailable */ - public function signatureRequestReleaseHoldWithHttpInfo(string $signature_request_id) + public function signatureRequestReleaseHoldWithHttpInfo(string $signature_request_id, string $contentType = self::contentTypes['signatureRequestReleaseHold'][0]) { - $request = $this->signatureRequestReleaseHoldRequest($signature_request_id); + $request = $this->signatureRequestReleaseHoldRequest($signature_request_id, $contentType); try { $options = $this->createHttpClientOption(); @@ -3331,14 +3544,14 @@ public function signatureRequestReleaseHoldWithHttpInfo(string $signature_reques } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -3351,51 +3564,73 @@ public function signatureRequestReleaseHoldWithHttpInfo(string $signature_reques sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\SignatureRequestGetResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\SignatureRequestGetResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\SignatureRequestGetResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\SignatureRequestGetResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\SignatureRequestGetResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\SignatureRequestGetResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -3404,28 +3639,19 @@ public function signatureRequestReleaseHoldWithHttpInfo(string $signature_reques $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\SignatureRequestGetResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\SignatureRequestGetResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -3436,13 +3662,15 @@ public function signatureRequestReleaseHoldWithHttpInfo(string $signature_reques * Release On-Hold Signature Request * * @param string $signature_request_id The id of the SignatureRequest to release. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestReleaseHold'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestReleaseHold. This method will eventually become unavailable */ - public function signatureRequestReleaseHoldAsync(string $signature_request_id) + public function signatureRequestReleaseHoldAsync(string $signature_request_id, string $contentType = self::contentTypes['signatureRequestReleaseHold'][0]) { - return $this->signatureRequestReleaseHoldAsyncWithHttpInfo($signature_request_id) + return $this->signatureRequestReleaseHoldAsyncWithHttpInfo($signature_request_id, $contentType) ->then( function ($response) { return $response[0]; @@ -3456,23 +3684,28 @@ function ($response) { * Release On-Hold Signature Request * * @param string $signature_request_id The id of the SignatureRequest to release. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestReleaseHold'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestReleaseHold. This method will eventually become unavailable */ - public function signatureRequestReleaseHoldAsyncWithHttpInfo(string $signature_request_id) + public function signatureRequestReleaseHoldAsyncWithHttpInfo(string $signature_request_id, string $contentType = self::contentTypes['signatureRequestReleaseHold'][0]) { $returnType = '\Dropbox\Sign\Model\SignatureRequestGetResponse'; - $request = $this->signatureRequestReleaseHoldRequest($signature_request_id); + $request = $this->signatureRequestReleaseHoldRequest($signature_request_id, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -3492,7 +3725,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -3502,11 +3735,13 @@ function ($exception) { * Create request for operation 'signatureRequestReleaseHold' * * @param string $signature_request_id The id of the SignatureRequest to release. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestReleaseHold'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::signatureRequestReleaseHold. This method will eventually become unavailable */ - public function signatureRequestReleaseHoldRequest(string $signature_request_id) + public function signatureRequestReleaseHoldRequest(string $signature_request_id, string $contentType = self::contentTypes['signatureRequestReleaseHold'][0]) { // verify the required parameter 'signature_request_id' is set if ($signature_request_id === null || (is_array($signature_request_id) && count($signature_request_id) === 0)) { @@ -3516,32 +3751,26 @@ public function signatureRequestReleaseHoldRequest(string $signature_request_id) } $resourcePath = '/signature_request/release_hold/{signature_request_id}'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // path params if ($signature_request_id !== null) { $resourcePath = str_replace( - '{' . 'signature_request_id' . '}', + '{signature_request_id}', ObjectSerializer::toPathValue($signature_request_id), $resourcePath ); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -3559,18 +3788,19 @@ public function signatureRequestReleaseHoldRequest(string $signature_request_id) // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -3594,11 +3824,11 @@ public function signatureRequestReleaseHoldRequest(string $signature_request_id) $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -3609,17 +3839,16 @@ public function signatureRequestReleaseHoldRequest(string $signature_request_id) * * Send Request Reminder * - * @param string $signature_request_id The id of the SignatureRequest to send a reminder for. (required) + * @param string $signature_request_id The id of the SignatureRequest to send a reminder for. (required) * @param Model\SignatureRequestRemindRequest $signature_request_remind_request signature_request_remind_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\SignatureRequestGetResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function signatureRequestRemind(string $signature_request_id, Model\SignatureRequestRemindRequest $signature_request_remind_request) { list($response) = $this->signatureRequestRemindWithHttpInfo($signature_request_id, $signature_request_remind_request); - return $response; } @@ -3628,16 +3857,18 @@ public function signatureRequestRemind(string $signature_request_id, Model\Signa * * Send Request Reminder * - * @param string $signature_request_id The id of the SignatureRequest to send a reminder for. (required) + * @param string $signature_request_id The id of the SignatureRequest to send a reminder for. (required) * @param Model\SignatureRequestRemindRequest $signature_request_remind_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestRemind'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\SignatureRequestGetResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::signatureRequestRemind. This method will eventually become unavailable */ - public function signatureRequestRemindWithHttpInfo(string $signature_request_id, Model\SignatureRequestRemindRequest $signature_request_remind_request) + public function signatureRequestRemindWithHttpInfo(string $signature_request_id, Model\SignatureRequestRemindRequest $signature_request_remind_request, string $contentType = self::contentTypes['signatureRequestRemind'][0]) { - $request = $this->signatureRequestRemindRequest($signature_request_id, $signature_request_remind_request); + $request = $this->signatureRequestRemindRequest($signature_request_id, $signature_request_remind_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -3647,14 +3878,14 @@ public function signatureRequestRemindWithHttpInfo(string $signature_request_id, } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -3667,51 +3898,73 @@ public function signatureRequestRemindWithHttpInfo(string $signature_request_id, sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\SignatureRequestGetResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\SignatureRequestGetResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\SignatureRequestGetResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\SignatureRequestGetResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\SignatureRequestGetResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\SignatureRequestGetResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -3720,28 +3973,19 @@ public function signatureRequestRemindWithHttpInfo(string $signature_request_id, $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\SignatureRequestGetResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\SignatureRequestGetResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -3751,15 +3995,17 @@ public function signatureRequestRemindWithHttpInfo(string $signature_request_id, * * Send Request Reminder * - * @param string $signature_request_id The id of the SignatureRequest to send a reminder for. (required) + * @param string $signature_request_id The id of the SignatureRequest to send a reminder for. (required) * @param Model\SignatureRequestRemindRequest $signature_request_remind_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestRemind'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestRemind. This method will eventually become unavailable */ - public function signatureRequestRemindAsync(string $signature_request_id, Model\SignatureRequestRemindRequest $signature_request_remind_request) + public function signatureRequestRemindAsync(string $signature_request_id, Model\SignatureRequestRemindRequest $signature_request_remind_request, string $contentType = self::contentTypes['signatureRequestRemind'][0]) { - return $this->signatureRequestRemindAsyncWithHttpInfo($signature_request_id, $signature_request_remind_request) + return $this->signatureRequestRemindAsyncWithHttpInfo($signature_request_id, $signature_request_remind_request, $contentType) ->then( function ($response) { return $response[0]; @@ -3772,25 +4018,30 @@ function ($response) { * * Send Request Reminder * - * @param string $signature_request_id The id of the SignatureRequest to send a reminder for. (required) + * @param string $signature_request_id The id of the SignatureRequest to send a reminder for. (required) * @param Model\SignatureRequestRemindRequest $signature_request_remind_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestRemind'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestRemind. This method will eventually become unavailable */ - public function signatureRequestRemindAsyncWithHttpInfo(string $signature_request_id, Model\SignatureRequestRemindRequest $signature_request_remind_request) + public function signatureRequestRemindAsyncWithHttpInfo(string $signature_request_id, Model\SignatureRequestRemindRequest $signature_request_remind_request, string $contentType = self::contentTypes['signatureRequestRemind'][0]) { $returnType = '\Dropbox\Sign\Model\SignatureRequestGetResponse'; - $request = $this->signatureRequestRemindRequest($signature_request_id, $signature_request_remind_request); + $request = $this->signatureRequestRemindRequest($signature_request_id, $signature_request_remind_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -3810,7 +4061,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -3819,13 +4070,15 @@ function ($exception) { /** * Create request for operation 'signatureRequestRemind' * - * @param string $signature_request_id The id of the SignatureRequest to send a reminder for. (required) + * @param string $signature_request_id The id of the SignatureRequest to send a reminder for. (required) * @param Model\SignatureRequestRemindRequest $signature_request_remind_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestRemind'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::signatureRequestRemind. This method will eventually become unavailable */ - public function signatureRequestRemindRequest(string $signature_request_id, Model\SignatureRequestRemindRequest $signature_request_remind_request) + public function signatureRequestRemindRequest(string $signature_request_id, Model\SignatureRequestRemindRequest $signature_request_remind_request, string $contentType = self::contentTypes['signatureRequestRemind'][0]) { // verify the required parameter 'signature_request_id' is set if ($signature_request_id === null || (is_array($signature_request_id) && count($signature_request_id) === 0)) { @@ -3833,6 +4086,7 @@ public function signatureRequestRemindRequest(string $signature_request_id, Mode 'Missing the required parameter $signature_request_id when calling signatureRequestRemind' ); } + // verify the required parameter 'signature_request_remind_request' is set if ($signature_request_remind_request === null || (is_array($signature_request_remind_request) && count($signature_request_remind_request) === 0)) { throw new InvalidArgumentException( @@ -3841,9 +4095,11 @@ public function signatureRequestRemindRequest(string $signature_request_id, Mode } $resourcePath = '/signature_request/remind/{signature_request_id}'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $signature_request_remind_request @@ -3854,27 +4110,23 @@ public function signatureRequestRemindRequest(string $signature_request_id, Mode // path params if ($signature_request_id !== null) { $resourcePath = str_replace( - '{' . 'signature_request_id' . '}', + '{signature_request_id}', ObjectSerializer::toPathValue($signature_request_id), $resourcePath ); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($signature_request_remind_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($signature_request_remind_request)); } else { $httpBody = $signature_request_remind_request; } @@ -3893,22 +4145,22 @@ public function signatureRequestRemindRequest(string $signature_request_id, Mode // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $signature_request_remind_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -3932,11 +4184,11 @@ public function signatureRequestRemindRequest(string $signature_request_id, Mode $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -3949,9 +4201,8 @@ public function signatureRequestRemindRequest(string $signature_request_id, Mode * * @param string $signature_request_id The id of the SignatureRequest to remove. (required) * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException - * @return void */ public function signatureRequestRemove(string $signature_request_id) { @@ -3964,14 +4215,16 @@ public function signatureRequestRemove(string $signature_request_id) * Remove Signature Request Access * * @param string $signature_request_id The id of the SignatureRequest to remove. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestRemove'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::signatureRequestRemove. This method will eventually become unavailable */ - public function signatureRequestRemoveWithHttpInfo(string $signature_request_id) + public function signatureRequestRemoveWithHttpInfo(string $signature_request_id, string $contentType = self::contentTypes['signatureRequestRemove'][0]) { - $request = $this->signatureRequestRemoveRequest($signature_request_id); + $request = $this->signatureRequestRemoveRequest($signature_request_id, $contentType); try { $options = $this->createHttpClientOption(); @@ -3981,14 +4234,14 @@ public function signatureRequestRemoveWithHttpInfo(string $signature_request_id) } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -4001,29 +4254,21 @@ public function signatureRequestRemoveWithHttpInfo(string $signature_request_id) sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } return [null, $statusCode, $response->getHeaders()]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { } - throw $e; } } @@ -4034,13 +4279,15 @@ public function signatureRequestRemoveWithHttpInfo(string $signature_request_id) * Remove Signature Request Access * * @param string $signature_request_id The id of the SignatureRequest to remove. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestRemove'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestRemove. This method will eventually become unavailable */ - public function signatureRequestRemoveAsync(string $signature_request_id) + public function signatureRequestRemoveAsync(string $signature_request_id, string $contentType = self::contentTypes['signatureRequestRemove'][0]) { - return $this->signatureRequestRemoveAsyncWithHttpInfo($signature_request_id) + return $this->signatureRequestRemoveAsyncWithHttpInfo($signature_request_id, $contentType) ->then( function ($response) { return $response[0]; @@ -4054,14 +4301,16 @@ function ($response) { * Remove Signature Request Access * * @param string $signature_request_id The id of the SignatureRequest to remove. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestRemove'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestRemove. This method will eventually become unavailable */ - public function signatureRequestRemoveAsyncWithHttpInfo(string $signature_request_id) + public function signatureRequestRemoveAsyncWithHttpInfo(string $signature_request_id, string $contentType = self::contentTypes['signatureRequestRemove'][0]) { $returnType = ''; - $request = $this->signatureRequestRemoveRequest($signature_request_id); + $request = $this->signatureRequestRemoveRequest($signature_request_id, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -4080,7 +4329,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -4090,11 +4339,13 @@ function ($exception) { * Create request for operation 'signatureRequestRemove' * * @param string $signature_request_id The id of the SignatureRequest to remove. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestRemove'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::signatureRequestRemove. This method will eventually become unavailable */ - public function signatureRequestRemoveRequest(string $signature_request_id) + public function signatureRequestRemoveRequest(string $signature_request_id, string $contentType = self::contentTypes['signatureRequestRemove'][0]) { // verify the required parameter 'signature_request_id' is set if ($signature_request_id === null || (is_array($signature_request_id) && count($signature_request_id) === 0)) { @@ -4104,32 +4355,26 @@ public function signatureRequestRemoveRequest(string $signature_request_id) } $resourcePath = '/signature_request/remove/{signature_request_id}'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // path params if ($signature_request_id !== null) { $resourcePath = str_replace( - '{' . 'signature_request_id' . '}', + '{signature_request_id}', ObjectSerializer::toPathValue($signature_request_id), $resourcePath ); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -4147,18 +4392,19 @@ public function signatureRequestRemoveRequest(string $signature_request_id) // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -4178,11 +4424,11 @@ public function signatureRequestRemoveRequest(string $signature_request_id) $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -4195,14 +4441,13 @@ public function signatureRequestRemoveRequest(string $signature_request_id) * * @param Model\SignatureRequestSendRequest $signature_request_send_request signature_request_send_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\SignatureRequestGetResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function signatureRequestSend(Model\SignatureRequestSendRequest $signature_request_send_request) { list($response) = $this->signatureRequestSendWithHttpInfo($signature_request_send_request); - return $response; } @@ -4212,14 +4457,16 @@ public function signatureRequestSend(Model\SignatureRequestSendRequest $signatur * Send Signature Request * * @param Model\SignatureRequestSendRequest $signature_request_send_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestSend'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\SignatureRequestGetResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::signatureRequestSend. This method will eventually become unavailable */ - public function signatureRequestSendWithHttpInfo(Model\SignatureRequestSendRequest $signature_request_send_request) + public function signatureRequestSendWithHttpInfo(Model\SignatureRequestSendRequest $signature_request_send_request, string $contentType = self::contentTypes['signatureRequestSend'][0]) { - $request = $this->signatureRequestSendRequest($signature_request_send_request); + $request = $this->signatureRequestSendRequest($signature_request_send_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -4229,14 +4476,14 @@ public function signatureRequestSendWithHttpInfo(Model\SignatureRequestSendReque } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -4249,51 +4496,73 @@ public function signatureRequestSendWithHttpInfo(Model\SignatureRequestSendReque sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\SignatureRequestGetResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\SignatureRequestGetResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\SignatureRequestGetResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\SignatureRequestGetResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\SignatureRequestGetResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\SignatureRequestGetResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -4302,28 +4571,19 @@ public function signatureRequestSendWithHttpInfo(Model\SignatureRequestSendReque $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\SignatureRequestGetResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\SignatureRequestGetResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -4334,13 +4594,15 @@ public function signatureRequestSendWithHttpInfo(Model\SignatureRequestSendReque * Send Signature Request * * @param Model\SignatureRequestSendRequest $signature_request_send_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestSend'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestSend. This method will eventually become unavailable */ - public function signatureRequestSendAsync(Model\SignatureRequestSendRequest $signature_request_send_request) + public function signatureRequestSendAsync(Model\SignatureRequestSendRequest $signature_request_send_request, string $contentType = self::contentTypes['signatureRequestSend'][0]) { - return $this->signatureRequestSendAsyncWithHttpInfo($signature_request_send_request) + return $this->signatureRequestSendAsyncWithHttpInfo($signature_request_send_request, $contentType) ->then( function ($response) { return $response[0]; @@ -4354,23 +4616,28 @@ function ($response) { * Send Signature Request * * @param Model\SignatureRequestSendRequest $signature_request_send_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestSend'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestSend. This method will eventually become unavailable */ - public function signatureRequestSendAsyncWithHttpInfo(Model\SignatureRequestSendRequest $signature_request_send_request) + public function signatureRequestSendAsyncWithHttpInfo(Model\SignatureRequestSendRequest $signature_request_send_request, string $contentType = self::contentTypes['signatureRequestSend'][0]) { $returnType = '\Dropbox\Sign\Model\SignatureRequestGetResponse'; - $request = $this->signatureRequestSendRequest($signature_request_send_request); + $request = $this->signatureRequestSendRequest($signature_request_send_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -4390,7 +4657,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -4400,11 +4667,13 @@ function ($exception) { * Create request for operation 'signatureRequestSend' * * @param Model\SignatureRequestSendRequest $signature_request_send_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestSend'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::signatureRequestSend. This method will eventually become unavailable */ - public function signatureRequestSendRequest(Model\SignatureRequestSendRequest $signature_request_send_request) + public function signatureRequestSendRequest(Model\SignatureRequestSendRequest $signature_request_send_request, string $contentType = self::contentTypes['signatureRequestSend'][0]) { // verify the required parameter 'signature_request_send_request' is set if ($signature_request_send_request === null || (is_array($signature_request_send_request) && count($signature_request_send_request) === 0)) { @@ -4414,9 +4683,11 @@ public function signatureRequestSendRequest(Model\SignatureRequestSendRequest $s } $resourcePath = '/signature_request/send'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $signature_request_send_request @@ -4424,21 +4695,17 @@ public function signatureRequestSendRequest(Model\SignatureRequestSendRequest $s $multipart = !empty($formParams); - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json', 'multipart/form-data'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($signature_request_send_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($signature_request_send_request)); } else { $httpBody = $signature_request_send_request; } @@ -4457,22 +4724,22 @@ public function signatureRequestSendRequest(Model\SignatureRequestSendRequest $s // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $signature_request_send_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -4496,11 +4763,11 @@ public function signatureRequestSendRequest(Model\SignatureRequestSendRequest $s $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -4513,14 +4780,13 @@ public function signatureRequestSendRequest(Model\SignatureRequestSendRequest $s * * @param Model\SignatureRequestSendWithTemplateRequest $signature_request_send_with_template_request signature_request_send_with_template_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\SignatureRequestGetResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function signatureRequestSendWithTemplate(Model\SignatureRequestSendWithTemplateRequest $signature_request_send_with_template_request) { list($response) = $this->signatureRequestSendWithTemplateWithHttpInfo($signature_request_send_with_template_request); - return $response; } @@ -4530,14 +4796,16 @@ public function signatureRequestSendWithTemplate(Model\SignatureRequestSendWithT * Send with Template * * @param Model\SignatureRequestSendWithTemplateRequest $signature_request_send_with_template_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestSendWithTemplate'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\SignatureRequestGetResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::signatureRequestSendWithTemplate. This method will eventually become unavailable */ - public function signatureRequestSendWithTemplateWithHttpInfo(Model\SignatureRequestSendWithTemplateRequest $signature_request_send_with_template_request) + public function signatureRequestSendWithTemplateWithHttpInfo(Model\SignatureRequestSendWithTemplateRequest $signature_request_send_with_template_request, string $contentType = self::contentTypes['signatureRequestSendWithTemplate'][0]) { - $request = $this->signatureRequestSendWithTemplateRequest($signature_request_send_with_template_request); + $request = $this->signatureRequestSendWithTemplateRequest($signature_request_send_with_template_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -4547,14 +4815,14 @@ public function signatureRequestSendWithTemplateWithHttpInfo(Model\SignatureRequ } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -4567,51 +4835,73 @@ public function signatureRequestSendWithTemplateWithHttpInfo(Model\SignatureRequ sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\SignatureRequestGetResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\SignatureRequestGetResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\SignatureRequestGetResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\SignatureRequestGetResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\SignatureRequestGetResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\SignatureRequestGetResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -4620,28 +4910,19 @@ public function signatureRequestSendWithTemplateWithHttpInfo(Model\SignatureRequ $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\SignatureRequestGetResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\SignatureRequestGetResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -4652,13 +4933,15 @@ public function signatureRequestSendWithTemplateWithHttpInfo(Model\SignatureRequ * Send with Template * * @param Model\SignatureRequestSendWithTemplateRequest $signature_request_send_with_template_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestSendWithTemplate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestSendWithTemplate. This method will eventually become unavailable */ - public function signatureRequestSendWithTemplateAsync(Model\SignatureRequestSendWithTemplateRequest $signature_request_send_with_template_request) + public function signatureRequestSendWithTemplateAsync(Model\SignatureRequestSendWithTemplateRequest $signature_request_send_with_template_request, string $contentType = self::contentTypes['signatureRequestSendWithTemplate'][0]) { - return $this->signatureRequestSendWithTemplateAsyncWithHttpInfo($signature_request_send_with_template_request) + return $this->signatureRequestSendWithTemplateAsyncWithHttpInfo($signature_request_send_with_template_request, $contentType) ->then( function ($response) { return $response[0]; @@ -4672,23 +4955,28 @@ function ($response) { * Send with Template * * @param Model\SignatureRequestSendWithTemplateRequest $signature_request_send_with_template_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestSendWithTemplate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestSendWithTemplate. This method will eventually become unavailable */ - public function signatureRequestSendWithTemplateAsyncWithHttpInfo(Model\SignatureRequestSendWithTemplateRequest $signature_request_send_with_template_request) + public function signatureRequestSendWithTemplateAsyncWithHttpInfo(Model\SignatureRequestSendWithTemplateRequest $signature_request_send_with_template_request, string $contentType = self::contentTypes['signatureRequestSendWithTemplate'][0]) { $returnType = '\Dropbox\Sign\Model\SignatureRequestGetResponse'; - $request = $this->signatureRequestSendWithTemplateRequest($signature_request_send_with_template_request); + $request = $this->signatureRequestSendWithTemplateRequest($signature_request_send_with_template_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -4708,7 +4996,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -4718,11 +5006,13 @@ function ($exception) { * Create request for operation 'signatureRequestSendWithTemplate' * * @param Model\SignatureRequestSendWithTemplateRequest $signature_request_send_with_template_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestSendWithTemplate'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::signatureRequestSendWithTemplate. This method will eventually become unavailable */ - public function signatureRequestSendWithTemplateRequest(Model\SignatureRequestSendWithTemplateRequest $signature_request_send_with_template_request) + public function signatureRequestSendWithTemplateRequest(Model\SignatureRequestSendWithTemplateRequest $signature_request_send_with_template_request, string $contentType = self::contentTypes['signatureRequestSendWithTemplate'][0]) { // verify the required parameter 'signature_request_send_with_template_request' is set if ($signature_request_send_with_template_request === null || (is_array($signature_request_send_with_template_request) && count($signature_request_send_with_template_request) === 0)) { @@ -4732,9 +5022,11 @@ public function signatureRequestSendWithTemplateRequest(Model\SignatureRequestSe } $resourcePath = '/signature_request/send_with_template'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $signature_request_send_with_template_request @@ -4742,21 +5034,17 @@ public function signatureRequestSendWithTemplateRequest(Model\SignatureRequestSe $multipart = !empty($formParams); - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json', 'multipart/form-data'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($signature_request_send_with_template_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($signature_request_send_with_template_request)); } else { $httpBody = $signature_request_send_with_template_request; } @@ -4775,22 +5063,22 @@ public function signatureRequestSendWithTemplateRequest(Model\SignatureRequestSe // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $signature_request_send_with_template_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -4814,11 +5102,11 @@ public function signatureRequestSendWithTemplateRequest(Model\SignatureRequestSe $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -4829,17 +5117,16 @@ public function signatureRequestSendWithTemplateRequest(Model\SignatureRequestSe * * Update Signature Request * - * @param string $signature_request_id The id of the SignatureRequest to update. (required) + * @param string $signature_request_id The id of the SignatureRequest to update. (required) * @param Model\SignatureRequestUpdateRequest $signature_request_update_request signature_request_update_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\SignatureRequestGetResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function signatureRequestUpdate(string $signature_request_id, Model\SignatureRequestUpdateRequest $signature_request_update_request) { list($response) = $this->signatureRequestUpdateWithHttpInfo($signature_request_id, $signature_request_update_request); - return $response; } @@ -4848,16 +5135,18 @@ public function signatureRequestUpdate(string $signature_request_id, Model\Signa * * Update Signature Request * - * @param string $signature_request_id The id of the SignatureRequest to update. (required) + * @param string $signature_request_id The id of the SignatureRequest to update. (required) * @param Model\SignatureRequestUpdateRequest $signature_request_update_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestUpdate'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\SignatureRequestGetResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::signatureRequestUpdate. This method will eventually become unavailable */ - public function signatureRequestUpdateWithHttpInfo(string $signature_request_id, Model\SignatureRequestUpdateRequest $signature_request_update_request) + public function signatureRequestUpdateWithHttpInfo(string $signature_request_id, Model\SignatureRequestUpdateRequest $signature_request_update_request, string $contentType = self::contentTypes['signatureRequestUpdate'][0]) { - $request = $this->signatureRequestUpdateRequest($signature_request_id, $signature_request_update_request); + $request = $this->signatureRequestUpdateRequest($signature_request_id, $signature_request_update_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -4867,14 +5156,14 @@ public function signatureRequestUpdateWithHttpInfo(string $signature_request_id, } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -4887,51 +5176,73 @@ public function signatureRequestUpdateWithHttpInfo(string $signature_request_id, sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\SignatureRequestGetResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\SignatureRequestGetResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\SignatureRequestGetResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\SignatureRequestGetResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\SignatureRequestGetResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\SignatureRequestGetResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -4940,28 +5251,19 @@ public function signatureRequestUpdateWithHttpInfo(string $signature_request_id, $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\SignatureRequestGetResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\SignatureRequestGetResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -4971,15 +5273,17 @@ public function signatureRequestUpdateWithHttpInfo(string $signature_request_id, * * Update Signature Request * - * @param string $signature_request_id The id of the SignatureRequest to update. (required) + * @param string $signature_request_id The id of the SignatureRequest to update. (required) * @param Model\SignatureRequestUpdateRequest $signature_request_update_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestUpdate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestUpdate. This method will eventually become unavailable */ - public function signatureRequestUpdateAsync(string $signature_request_id, Model\SignatureRequestUpdateRequest $signature_request_update_request) + public function signatureRequestUpdateAsync(string $signature_request_id, Model\SignatureRequestUpdateRequest $signature_request_update_request, string $contentType = self::contentTypes['signatureRequestUpdate'][0]) { - return $this->signatureRequestUpdateAsyncWithHttpInfo($signature_request_id, $signature_request_update_request) + return $this->signatureRequestUpdateAsyncWithHttpInfo($signature_request_id, $signature_request_update_request, $contentType) ->then( function ($response) { return $response[0]; @@ -4992,25 +5296,30 @@ function ($response) { * * Update Signature Request * - * @param string $signature_request_id The id of the SignatureRequest to update. (required) + * @param string $signature_request_id The id of the SignatureRequest to update. (required) * @param Model\SignatureRequestUpdateRequest $signature_request_update_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestUpdate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::signatureRequestUpdate. This method will eventually become unavailable */ - public function signatureRequestUpdateAsyncWithHttpInfo(string $signature_request_id, Model\SignatureRequestUpdateRequest $signature_request_update_request) + public function signatureRequestUpdateAsyncWithHttpInfo(string $signature_request_id, Model\SignatureRequestUpdateRequest $signature_request_update_request, string $contentType = self::contentTypes['signatureRequestUpdate'][0]) { $returnType = '\Dropbox\Sign\Model\SignatureRequestGetResponse'; - $request = $this->signatureRequestUpdateRequest($signature_request_id, $signature_request_update_request); + $request = $this->signatureRequestUpdateRequest($signature_request_id, $signature_request_update_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -5030,7 +5339,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -5039,13 +5348,15 @@ function ($exception) { /** * Create request for operation 'signatureRequestUpdate' * - * @param string $signature_request_id The id of the SignatureRequest to update. (required) + * @param string $signature_request_id The id of the SignatureRequest to update. (required) * @param Model\SignatureRequestUpdateRequest $signature_request_update_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['signatureRequestUpdate'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::signatureRequestUpdate. This method will eventually become unavailable */ - public function signatureRequestUpdateRequest(string $signature_request_id, Model\SignatureRequestUpdateRequest $signature_request_update_request) + public function signatureRequestUpdateRequest(string $signature_request_id, Model\SignatureRequestUpdateRequest $signature_request_update_request, string $contentType = self::contentTypes['signatureRequestUpdate'][0]) { // verify the required parameter 'signature_request_id' is set if ($signature_request_id === null || (is_array($signature_request_id) && count($signature_request_id) === 0)) { @@ -5053,6 +5364,7 @@ public function signatureRequestUpdateRequest(string $signature_request_id, Mode 'Missing the required parameter $signature_request_id when calling signatureRequestUpdate' ); } + // verify the required parameter 'signature_request_update_request' is set if ($signature_request_update_request === null || (is_array($signature_request_update_request) && count($signature_request_update_request) === 0)) { throw new InvalidArgumentException( @@ -5061,9 +5373,11 @@ public function signatureRequestUpdateRequest(string $signature_request_id, Mode } $resourcePath = '/signature_request/update/{signature_request_id}'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $signature_request_update_request @@ -5074,27 +5388,23 @@ public function signatureRequestUpdateRequest(string $signature_request_id, Mode // path params if ($signature_request_id !== null) { $resourcePath = str_replace( - '{' . 'signature_request_id' . '}', + '{signature_request_id}', ObjectSerializer::toPathValue($signature_request_id), $resourcePath ); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($signature_request_update_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($signature_request_update_request)); } else { $httpBody = $signature_request_update_request; } @@ -5113,22 +5423,22 @@ public function signatureRequestUpdateRequest(string $signature_request_id, Mode // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $signature_request_update_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -5152,11 +5462,11 @@ public function signatureRequestUpdateRequest(string $signature_request_id, Mode $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -5165,8 +5475,8 @@ public function signatureRequestUpdateRequest(string $signature_request_id, Mode /** * Create http client option * - * @throws RuntimeException on file opening failure * @return array of http client options + * @throws RuntimeException on file opening failure */ protected function createHttpClientOption() { @@ -5180,4 +5490,66 @@ protected function createHttpClientOption() return $options; } + + /** + * @return object|array|null + */ + private function handleRangeCodeResponse( + ResponseInterface $response, + string $rangeCode, + string $returnDataType + ) { + $statusCode = $response->getStatusCode(); + $rangeCodeLeft = (int)(substr($rangeCode, 0, 1) . '00'); + $rangeCodeRight = (int)(substr($rangeCode, 0, 1) . '99'); + + if ( + $statusCode < $rangeCodeLeft + || $statusCode > $rangeCodeRight + ) { + return null; + } + + if ($returnDataType === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + } + + return [ + ObjectSerializer::deserialize($content, $returnDataType, []), + $statusCode, + $response->getHeaders(), + ]; + } + + /** + * @return object|array|null + */ + private function handleRangeCodeException( + ApiException $e, + string $rangeCode, + string $exceptionDataType + ): bool { + $statusCode = $e->getCode(); + $rangeCodeLeft = (int)(substr($rangeCode, 0, 1) . '00'); + $rangeCodeRight = (int)(substr($rangeCode, 0, 1) . '99'); + + if ( + $statusCode < $rangeCodeLeft + || $statusCode > $rangeCodeRight + ) { + return false; + } + + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + $exceptionDataType, + $e->getResponseHeaders() + ); + + $e->setResponseObject($data); + + return true; + } } diff --git a/sdks/php/src/Api/TeamApi.php b/sdks/php/src/Api/TeamApi.php index c0883aa81..ec599b4ac 100644 --- a/sdks/php/src/Api/TeamApi.php +++ b/sdks/php/src/Api/TeamApi.php @@ -4,7 +4,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -16,7 +15,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -36,11 +35,11 @@ use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Promise; -use GuzzleHttp\Psr7; +use GuzzleHttp\Psr7\MultipartStream; +use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; -use GuzzleHttp\Utils; use InvalidArgumentException; +use JsonException; use Psr\Http\Message\ResponseInterface; use RuntimeException; @@ -48,34 +47,59 @@ * TeamApi Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ class TeamApi { - /** - * @var ClientInterface - */ + /** @var ClientInterface */ protected $client; - /** - * @var Configuration - */ + /** @var Configuration */ protected $config; - /** - * @var HeaderSelector - */ + /** @var HeaderSelector */ protected $headerSelector; - /** - * @var int Host index - */ + /** @var int Host index */ protected $hostIndex; /** - * @var ResponseInterface|null + * @var string[] * */ + public const contentTypes = [ + 'teamAddMember' => [ + 'application/json', + ], + 'teamCreate' => [ + 'application/json', + ], + 'teamDelete' => [ + 'application/json', + ], + 'teamGet' => [ + 'application/json', + ], + 'teamInfo' => [ + 'application/json', + ], + 'teamInvites' => [ + 'application/json', + ], + 'teamMembers' => [ + 'application/json', + ], + 'teamRemoveMember' => [ + 'application/json', + ], + 'teamSubTeams' => [ + 'application/json', + ], + 'teamUpdate' => [ + 'application/json', + ], + ]; + + /** @var ResponseInterface|null */ protected $response; /** @@ -97,6 +121,7 @@ public function __construct( * Set the host index * * @param int $hostIndex Host index (required) + * @deprecated To be made private in the future */ public function setHostIndex(int $hostIndex): void { @@ -107,6 +132,7 @@ public function setHostIndex(int $hostIndex): void * Get the host index * * @return int Host index + * @deprecated To be made private in the future */ public function getHostIndex() { @@ -135,16 +161,15 @@ public function getResponse() * Add User to Team * * @param Model\TeamAddMemberRequest $team_add_member_request team_add_member_request (required) - * @param string $team_id The id of the team. (optional) + * @param string $team_id The id of the team. (optional) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\TeamGetResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function teamAddMember(Model\TeamAddMemberRequest $team_add_member_request, string $team_id = null) { list($response) = $this->teamAddMemberWithHttpInfo($team_add_member_request, $team_id); - return $response; } @@ -154,15 +179,17 @@ public function teamAddMember(Model\TeamAddMemberRequest $team_add_member_reques * Add User to Team * * @param Model\TeamAddMemberRequest $team_add_member_request (required) - * @param string $team_id The id of the team. (optional) + * @param string $team_id The id of the team. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamAddMember'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\TeamGetResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::teamAddMember. This method will eventually become unavailable */ - public function teamAddMemberWithHttpInfo(Model\TeamAddMemberRequest $team_add_member_request, string $team_id = null) + public function teamAddMemberWithHttpInfo(Model\TeamAddMemberRequest $team_add_member_request, string $team_id = null, string $contentType = self::contentTypes['teamAddMember'][0]) { - $request = $this->teamAddMemberRequest($team_add_member_request, $team_id); + $request = $this->teamAddMemberRequest($team_add_member_request, $team_id, $contentType); try { $options = $this->createHttpClientOption(); @@ -172,14 +199,14 @@ public function teamAddMemberWithHttpInfo(Model\TeamAddMemberRequest $team_add_m } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -192,51 +219,73 @@ public function teamAddMemberWithHttpInfo(Model\TeamAddMemberRequest $team_add_m sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\TeamGetResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TeamGetResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\TeamGetResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\TeamGetResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TeamGetResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\TeamGetResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -245,28 +294,19 @@ public function teamAddMemberWithHttpInfo(Model\TeamAddMemberRequest $team_add_m $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\TeamGetResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\TeamGetResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -277,14 +317,16 @@ public function teamAddMemberWithHttpInfo(Model\TeamAddMemberRequest $team_add_m * Add User to Team * * @param Model\TeamAddMemberRequest $team_add_member_request (required) - * @param string $team_id The id of the team. (optional) + * @param string $team_id The id of the team. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamAddMember'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::teamAddMember. This method will eventually become unavailable */ - public function teamAddMemberAsync(Model\TeamAddMemberRequest $team_add_member_request, string $team_id = null) + public function teamAddMemberAsync(Model\TeamAddMemberRequest $team_add_member_request, string $team_id = null, string $contentType = self::contentTypes['teamAddMember'][0]) { - return $this->teamAddMemberAsyncWithHttpInfo($team_add_member_request, $team_id) + return $this->teamAddMemberAsyncWithHttpInfo($team_add_member_request, $team_id, $contentType) ->then( function ($response) { return $response[0]; @@ -298,24 +340,29 @@ function ($response) { * Add User to Team * * @param Model\TeamAddMemberRequest $team_add_member_request (required) - * @param string $team_id The id of the team. (optional) + * @param string $team_id The id of the team. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamAddMember'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::teamAddMember. This method will eventually become unavailable */ - public function teamAddMemberAsyncWithHttpInfo(Model\TeamAddMemberRequest $team_add_member_request, string $team_id = null) + public function teamAddMemberAsyncWithHttpInfo(Model\TeamAddMemberRequest $team_add_member_request, string $team_id = null, string $contentType = self::contentTypes['teamAddMember'][0]) { $returnType = '\Dropbox\Sign\Model\TeamGetResponse'; - $request = $this->teamAddMemberRequest($team_add_member_request, $team_id); + $request = $this->teamAddMemberRequest($team_add_member_request, $team_id, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -335,7 +382,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -345,12 +392,14 @@ function ($exception) { * Create request for operation 'teamAddMember' * * @param Model\TeamAddMemberRequest $team_add_member_request (required) - * @param string $team_id The id of the team. (optional) + * @param string $team_id The id of the team. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamAddMember'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::teamAddMember. This method will eventually become unavailable */ - public function teamAddMemberRequest(Model\TeamAddMemberRequest $team_add_member_request, string $team_id = null) + public function teamAddMemberRequest(Model\TeamAddMemberRequest $team_add_member_request, string $team_id = null, string $contentType = self::contentTypes['teamAddMember'][0]) { // verify the required parameter 'team_add_member_request' is set if ($team_add_member_request === null || (is_array($team_add_member_request) && count($team_add_member_request) === 0)) { @@ -360,42 +409,38 @@ public function teamAddMemberRequest(Model\TeamAddMemberRequest $team_add_member } $resourcePath = '/team/add_member'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $team_add_member_request ); $multipart = !empty($formParams); - // query params - if ($team_id !== null) { - if ('form' === 'form' && is_array($team_id)) { - foreach ($team_id as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['team_id'] = $team_id; - } - } - - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $team_id, + 'team_id', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($team_add_member_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($team_add_member_request)); } else { $httpBody = $team_add_member_request; } @@ -414,22 +459,22 @@ public function teamAddMemberRequest(Model\TeamAddMemberRequest $team_add_member // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $team_add_member_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -453,11 +498,11 @@ public function teamAddMemberRequest(Model\TeamAddMemberRequest $team_add_member $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'PUT', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -470,14 +515,13 @@ public function teamAddMemberRequest(Model\TeamAddMemberRequest $team_add_member * * @param Model\TeamCreateRequest $team_create_request team_create_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\TeamGetResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function teamCreate(Model\TeamCreateRequest $team_create_request) { list($response) = $this->teamCreateWithHttpInfo($team_create_request); - return $response; } @@ -487,14 +531,16 @@ public function teamCreate(Model\TeamCreateRequest $team_create_request) * Create Team * * @param Model\TeamCreateRequest $team_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamCreate'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\TeamGetResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::teamCreate. This method will eventually become unavailable */ - public function teamCreateWithHttpInfo(Model\TeamCreateRequest $team_create_request) + public function teamCreateWithHttpInfo(Model\TeamCreateRequest $team_create_request, string $contentType = self::contentTypes['teamCreate'][0]) { - $request = $this->teamCreateRequest($team_create_request); + $request = $this->teamCreateRequest($team_create_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -504,14 +550,14 @@ public function teamCreateWithHttpInfo(Model\TeamCreateRequest $team_create_requ } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -524,51 +570,73 @@ public function teamCreateWithHttpInfo(Model\TeamCreateRequest $team_create_requ sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\TeamGetResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TeamGetResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\TeamGetResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\TeamGetResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TeamGetResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\TeamGetResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -577,28 +645,19 @@ public function teamCreateWithHttpInfo(Model\TeamCreateRequest $team_create_requ $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\TeamGetResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\TeamGetResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -609,13 +668,15 @@ public function teamCreateWithHttpInfo(Model\TeamCreateRequest $team_create_requ * Create Team * * @param Model\TeamCreateRequest $team_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamCreate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::teamCreate. This method will eventually become unavailable */ - public function teamCreateAsync(Model\TeamCreateRequest $team_create_request) + public function teamCreateAsync(Model\TeamCreateRequest $team_create_request, string $contentType = self::contentTypes['teamCreate'][0]) { - return $this->teamCreateAsyncWithHttpInfo($team_create_request) + return $this->teamCreateAsyncWithHttpInfo($team_create_request, $contentType) ->then( function ($response) { return $response[0]; @@ -629,23 +690,28 @@ function ($response) { * Create Team * * @param Model\TeamCreateRequest $team_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamCreate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::teamCreate. This method will eventually become unavailable */ - public function teamCreateAsyncWithHttpInfo(Model\TeamCreateRequest $team_create_request) + public function teamCreateAsyncWithHttpInfo(Model\TeamCreateRequest $team_create_request, string $contentType = self::contentTypes['teamCreate'][0]) { $returnType = '\Dropbox\Sign\Model\TeamGetResponse'; - $request = $this->teamCreateRequest($team_create_request); + $request = $this->teamCreateRequest($team_create_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -665,7 +731,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -675,11 +741,13 @@ function ($exception) { * Create request for operation 'teamCreate' * * @param Model\TeamCreateRequest $team_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamCreate'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::teamCreate. This method will eventually become unavailable */ - public function teamCreateRequest(Model\TeamCreateRequest $team_create_request) + public function teamCreateRequest(Model\TeamCreateRequest $team_create_request, string $contentType = self::contentTypes['teamCreate'][0]) { // verify the required parameter 'team_create_request' is set if ($team_create_request === null || (is_array($team_create_request) && count($team_create_request) === 0)) { @@ -689,9 +757,11 @@ public function teamCreateRequest(Model\TeamCreateRequest $team_create_request) } $resourcePath = '/team/create'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $team_create_request @@ -699,21 +769,17 @@ public function teamCreateRequest(Model\TeamCreateRequest $team_create_request) $multipart = !empty($formParams); - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($team_create_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($team_create_request)); } else { $httpBody = $team_create_request; } @@ -732,22 +798,22 @@ public function teamCreateRequest(Model\TeamCreateRequest $team_create_request) // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $team_create_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -771,11 +837,11 @@ public function teamCreateRequest(Model\TeamCreateRequest $team_create_request) $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -786,9 +852,8 @@ public function teamCreateRequest(Model\TeamCreateRequest $team_create_request) * * Delete Team * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException - * @return void */ public function teamDelete() { @@ -800,13 +865,16 @@ public function teamDelete() * * Delete Team * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamDelete'] to see the possible values for this operation + * * @return array of null, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::teamDelete. This method will eventually become unavailable */ - public function teamDeleteWithHttpInfo() + public function teamDeleteWithHttpInfo(string $contentType = self::contentTypes['teamDelete'][0]) { - $request = $this->teamDeleteRequest(); + $request = $this->teamDeleteRequest($contentType); try { $options = $this->createHttpClientOption(); @@ -816,14 +884,14 @@ public function teamDeleteWithHttpInfo() } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -836,29 +904,21 @@ public function teamDeleteWithHttpInfo() sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } return [null, $statusCode, $response->getHeaders()]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { } - throw $e; } } @@ -868,12 +928,15 @@ public function teamDeleteWithHttpInfo() * * Delete Team * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamDelete'] to see the possible values for this operation + * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::teamDelete. This method will eventually become unavailable */ - public function teamDeleteAsync() + public function teamDeleteAsync(string $contentType = self::contentTypes['teamDelete'][0]) { - return $this->teamDeleteAsyncWithHttpInfo() + return $this->teamDeleteAsyncWithHttpInfo($contentType) ->then( function ($response) { return $response[0]; @@ -886,13 +949,16 @@ function ($response) { * * Delete Team * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamDelete'] to see the possible values for this operation + * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::teamDelete. This method will eventually become unavailable */ - public function teamDeleteAsyncWithHttpInfo() + public function teamDeleteAsyncWithHttpInfo(string $contentType = self::contentTypes['teamDelete'][0]) { $returnType = ''; - $request = $this->teamDeleteRequest(); + $request = $this->teamDeleteRequest($contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -911,7 +977,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -920,29 +986,26 @@ function ($exception) { /** * Create request for operation 'teamDelete' * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamDelete'] to see the possible values for this operation + * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::teamDelete. This method will eventually become unavailable */ - public function teamDeleteRequest() + public function teamDeleteRequest(string $contentType = self::contentTypes['teamDelete'][0]) { $resourcePath = '/team/destroy'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -960,18 +1023,19 @@ public function teamDeleteRequest() // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -995,11 +1059,11 @@ public function teamDeleteRequest() $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'DELETE', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1010,14 +1074,13 @@ public function teamDeleteRequest() * * Get Team * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\TeamGetResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function teamGet() { list($response) = $this->teamGetWithHttpInfo(); - return $response; } @@ -1026,13 +1089,16 @@ public function teamGet() * * Get Team * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamGet'] to see the possible values for this operation + * * @return array of Model\TeamGetResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::teamGet. This method will eventually become unavailable */ - public function teamGetWithHttpInfo() + public function teamGetWithHttpInfo(string $contentType = self::contentTypes['teamGet'][0]) { - $request = $this->teamGetRequest(); + $request = $this->teamGetRequest($contentType); try { $options = $this->createHttpClientOption(); @@ -1042,14 +1108,14 @@ public function teamGetWithHttpInfo() } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -1062,51 +1128,73 @@ public function teamGetWithHttpInfo() sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\TeamGetResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TeamGetResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\TeamGetResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\TeamGetResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TeamGetResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\TeamGetResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -1115,28 +1203,19 @@ public function teamGetWithHttpInfo() $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\TeamGetResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\TeamGetResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -1146,12 +1225,15 @@ public function teamGetWithHttpInfo() * * Get Team * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamGet'] to see the possible values for this operation + * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::teamGet. This method will eventually become unavailable */ - public function teamGetAsync() + public function teamGetAsync(string $contentType = self::contentTypes['teamGet'][0]) { - return $this->teamGetAsyncWithHttpInfo() + return $this->teamGetAsyncWithHttpInfo($contentType) ->then( function ($response) { return $response[0]; @@ -1164,22 +1246,28 @@ function ($response) { * * Get Team * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamGet'] to see the possible values for this operation + * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::teamGet. This method will eventually become unavailable */ - public function teamGetAsyncWithHttpInfo() + public function teamGetAsyncWithHttpInfo(string $contentType = self::contentTypes['teamGet'][0]) { $returnType = '\Dropbox\Sign\Model\TeamGetResponse'; - $request = $this->teamGetRequest(); + $request = $this->teamGetRequest($contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -1199,7 +1287,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -1208,29 +1296,26 @@ function ($exception) { /** * Create request for operation 'teamGet' * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamGet'] to see the possible values for this operation + * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::teamGet. This method will eventually become unavailable */ - public function teamGetRequest() + public function teamGetRequest(string $contentType = self::contentTypes['teamGet'][0]) { $resourcePath = '/team'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -1248,18 +1333,19 @@ public function teamGetRequest() // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -1283,11 +1369,11 @@ public function teamGetRequest() $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'GET', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1300,14 +1386,13 @@ public function teamGetRequest() * * @param string $team_id The id of the team. (optional) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\TeamGetInfoResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function teamInfo(string $team_id = null) { list($response) = $this->teamInfoWithHttpInfo($team_id); - return $response; } @@ -1316,15 +1401,17 @@ public function teamInfo(string $team_id = null) * * Get Team Info * - * @param string $team_id The id of the team. (optional) + * @param string $team_id The id of the team. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamInfo'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\TeamGetInfoResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::teamInfo. This method will eventually become unavailable */ - public function teamInfoWithHttpInfo(string $team_id = null) + public function teamInfoWithHttpInfo(string $team_id = null, string $contentType = self::contentTypes['teamInfo'][0]) { - $request = $this->teamInfoRequest($team_id); + $request = $this->teamInfoRequest($team_id, $contentType); try { $options = $this->createHttpClientOption(); @@ -1334,14 +1421,14 @@ public function teamInfoWithHttpInfo(string $team_id = null) } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -1354,51 +1441,73 @@ public function teamInfoWithHttpInfo(string $team_id = null) sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\TeamGetInfoResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TeamGetInfoResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\TeamGetInfoResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\TeamGetInfoResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TeamGetInfoResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\TeamGetInfoResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -1407,28 +1516,19 @@ public function teamInfoWithHttpInfo(string $team_id = null) $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\TeamGetInfoResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\TeamGetInfoResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -1438,14 +1538,16 @@ public function teamInfoWithHttpInfo(string $team_id = null) * * Get Team Info * - * @param string $team_id The id of the team. (optional) + * @param string $team_id The id of the team. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamInfo'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::teamInfo. This method will eventually become unavailable */ - public function teamInfoAsync(string $team_id = null) + public function teamInfoAsync(string $team_id = null, string $contentType = self::contentTypes['teamInfo'][0]) { - return $this->teamInfoAsyncWithHttpInfo($team_id) + return $this->teamInfoAsyncWithHttpInfo($team_id, $contentType) ->then( function ($response) { return $response[0]; @@ -1458,24 +1560,29 @@ function ($response) { * * Get Team Info * - * @param string $team_id The id of the team. (optional) + * @param string $team_id The id of the team. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamInfo'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::teamInfo. This method will eventually become unavailable */ - public function teamInfoAsyncWithHttpInfo(string $team_id = null) + public function teamInfoAsyncWithHttpInfo(string $team_id = null, string $contentType = self::contentTypes['teamInfo'][0]) { $returnType = '\Dropbox\Sign\Model\TeamGetInfoResponse'; - $request = $this->teamInfoRequest($team_id); + $request = $this->teamInfoRequest($team_id, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -1495,7 +1602,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -1504,42 +1611,37 @@ function ($exception) { /** * Create request for operation 'teamInfo' * - * @param string $team_id The id of the team. (optional) + * @param string $team_id The id of the team. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamInfo'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::teamInfo. This method will eventually become unavailable */ - public function teamInfoRequest(string $team_id = null) + public function teamInfoRequest(string $team_id = null, string $contentType = self::contentTypes['teamInfo'][0]) { $resourcePath = '/team/info'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // query params - if ($team_id !== null) { - if ('form' === 'form' && is_array($team_id)) { - foreach ($team_id as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['team_id'] = $team_id; - } - } - - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $team_id, + 'team_id', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -1557,18 +1659,19 @@ public function teamInfoRequest(string $team_id = null) // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -1592,11 +1695,11 @@ public function teamInfoRequest(string $team_id = null) $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'GET', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1609,14 +1712,13 @@ public function teamInfoRequest(string $team_id = null) * * @param string $email_address The email address for which to display the team invites. (optional) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\TeamInvitesResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function teamInvites(string $email_address = null) { list($response) = $this->teamInvitesWithHttpInfo($email_address); - return $response; } @@ -1626,14 +1728,16 @@ public function teamInvites(string $email_address = null) * List Team Invites * * @param string $email_address The email address for which to display the team invites. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamInvites'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\TeamInvitesResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::teamInvites. This method will eventually become unavailable */ - public function teamInvitesWithHttpInfo(string $email_address = null) + public function teamInvitesWithHttpInfo(string $email_address = null, string $contentType = self::contentTypes['teamInvites'][0]) { - $request = $this->teamInvitesRequest($email_address); + $request = $this->teamInvitesRequest($email_address, $contentType); try { $options = $this->createHttpClientOption(); @@ -1643,14 +1747,14 @@ public function teamInvitesWithHttpInfo(string $email_address = null) } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -1663,51 +1767,73 @@ public function teamInvitesWithHttpInfo(string $email_address = null) sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\TeamInvitesResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TeamInvitesResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\TeamInvitesResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\TeamInvitesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TeamInvitesResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\TeamInvitesResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -1716,28 +1842,19 @@ public function teamInvitesWithHttpInfo(string $email_address = null) $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\TeamInvitesResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\TeamInvitesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -1748,13 +1865,15 @@ public function teamInvitesWithHttpInfo(string $email_address = null) * List Team Invites * * @param string $email_address The email address for which to display the team invites. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamInvites'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::teamInvites. This method will eventually become unavailable */ - public function teamInvitesAsync(string $email_address = null) + public function teamInvitesAsync(string $email_address = null, string $contentType = self::contentTypes['teamInvites'][0]) { - return $this->teamInvitesAsyncWithHttpInfo($email_address) + return $this->teamInvitesAsyncWithHttpInfo($email_address, $contentType) ->then( function ($response) { return $response[0]; @@ -1768,23 +1887,28 @@ function ($response) { * List Team Invites * * @param string $email_address The email address for which to display the team invites. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamInvites'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::teamInvites. This method will eventually become unavailable */ - public function teamInvitesAsyncWithHttpInfo(string $email_address = null) + public function teamInvitesAsyncWithHttpInfo(string $email_address = null, string $contentType = self::contentTypes['teamInvites'][0]) { $returnType = '\Dropbox\Sign\Model\TeamInvitesResponse'; - $request = $this->teamInvitesRequest($email_address); + $request = $this->teamInvitesRequest($email_address, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -1804,7 +1928,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -1814,41 +1938,36 @@ function ($exception) { * Create request for operation 'teamInvites' * * @param string $email_address The email address for which to display the team invites. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamInvites'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::teamInvites. This method will eventually become unavailable */ - public function teamInvitesRequest(string $email_address = null) + public function teamInvitesRequest(string $email_address = null, string $contentType = self::contentTypes['teamInvites'][0]) { $resourcePath = '/team/invites'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // query params - if ($email_address !== null) { - if ('form' === 'form' && is_array($email_address)) { - foreach ($email_address as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['email_address'] = $email_address; - } - } - - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $email_address, + 'email_address', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -1866,18 +1985,19 @@ public function teamInvitesRequest(string $email_address = null) // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -1901,11 +2021,11 @@ public function teamInvitesRequest(string $email_address = null) $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'GET', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1916,18 +2036,17 @@ public function teamInvitesRequest(string $email_address = null) * * List Team Members * - * @param string $team_id The id of the team that a member list is being requested from. (required) - * @param int $page Which page number of the team member list to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $team_id The id of the team that a member list is being requested from. (required) + * @param int $page Which page number of the team member list to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\TeamMembersResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function teamMembers(string $team_id, int $page = 1, int $page_size = 20) { list($response) = $this->teamMembersWithHttpInfo($team_id, $page, $page_size); - return $response; } @@ -1936,17 +2055,19 @@ public function teamMembers(string $team_id, int $page = 1, int $page_size = 20) * * List Team Members * - * @param string $team_id The id of the team that a member list is being requested from. (required) - * @param int $page Which page number of the team member list to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $team_id The id of the team that a member list is being requested from. (required) + * @param int $page Which page number of the team member list to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamMembers'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\TeamMembersResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::teamMembers. This method will eventually become unavailable */ - public function teamMembersWithHttpInfo(string $team_id, int $page = 1, int $page_size = 20) + public function teamMembersWithHttpInfo(string $team_id, int $page = 1, int $page_size = 20, string $contentType = self::contentTypes['teamMembers'][0]) { - $request = $this->teamMembersRequest($team_id, $page, $page_size); + $request = $this->teamMembersRequest($team_id, $page, $page_size, $contentType); try { $options = $this->createHttpClientOption(); @@ -1956,14 +2077,14 @@ public function teamMembersWithHttpInfo(string $team_id, int $page = 1, int $pag } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -1976,51 +2097,73 @@ public function teamMembersWithHttpInfo(string $team_id, int $page = 1, int $pag sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\TeamMembersResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TeamMembersResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\TeamMembersResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\TeamMembersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TeamMembersResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\TeamMembersResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -2029,28 +2172,19 @@ public function teamMembersWithHttpInfo(string $team_id, int $page = 1, int $pag $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\TeamMembersResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\TeamMembersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -2060,16 +2194,18 @@ public function teamMembersWithHttpInfo(string $team_id, int $page = 1, int $pag * * List Team Members * - * @param string $team_id The id of the team that a member list is being requested from. (required) - * @param int $page Which page number of the team member list to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $team_id The id of the team that a member list is being requested from. (required) + * @param int $page Which page number of the team member list to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamMembers'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::teamMembers. This method will eventually become unavailable */ - public function teamMembersAsync(string $team_id, int $page = 1, int $page_size = 20) + public function teamMembersAsync(string $team_id, int $page = 1, int $page_size = 20, string $contentType = self::contentTypes['teamMembers'][0]) { - return $this->teamMembersAsyncWithHttpInfo($team_id, $page, $page_size) + return $this->teamMembersAsyncWithHttpInfo($team_id, $page, $page_size, $contentType) ->then( function ($response) { return $response[0]; @@ -2082,26 +2218,31 @@ function ($response) { * * List Team Members * - * @param string $team_id The id of the team that a member list is being requested from. (required) - * @param int $page Which page number of the team member list to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $team_id The id of the team that a member list is being requested from. (required) + * @param int $page Which page number of the team member list to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamMembers'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::teamMembers. This method will eventually become unavailable */ - public function teamMembersAsyncWithHttpInfo(string $team_id, int $page = 1, int $page_size = 20) + public function teamMembersAsyncWithHttpInfo(string $team_id, int $page = 1, int $page_size = 20, string $contentType = self::contentTypes['teamMembers'][0]) { $returnType = '\Dropbox\Sign\Model\TeamMembersResponse'; - $request = $this->teamMembersRequest($team_id, $page, $page_size); + $request = $this->teamMembersRequest($team_id, $page, $page_size, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -2121,7 +2262,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -2130,14 +2271,16 @@ function ($exception) { /** * Create request for operation 'teamMembers' * - * @param string $team_id The id of the team that a member list is being requested from. (required) - * @param int $page Which page number of the team member list to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $team_id The id of the team that a member list is being requested from. (required) + * @param int $page Which page number of the team member list to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamMembers'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::teamMembers. This method will eventually become unavailable */ - public function teamMembersRequest(string $team_id, int $page = 1, int $page_size = 20) + public function teamMembersRequest(string $team_id, int $page = 1, int $page_size = 20, string $contentType = self::contentTypes['teamMembers'][0]) { // verify the required parameter 'team_id' is set if ($team_id === null || (is_array($team_id) && count($team_id) === 0)) { @@ -2145,6 +2288,7 @@ public function teamMembersRequest(string $team_id, int $page = 1, int $page_siz 'Missing the required parameter $team_id when calling teamMembers' ); } + if ($page_size !== null && $page_size > 100) { throw new InvalidArgumentException('invalid value for "$page_size" when calling TeamApi.teamMembers, must be smaller than or equal to 100.'); } @@ -2153,53 +2297,45 @@ public function teamMembersRequest(string $team_id, int $page = 1, int $page_siz } $resourcePath = '/team/members/{team_id}'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // query params - if ($page !== null) { - if ('form' === 'form' && is_array($page)) { - foreach ($page as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['page'] = $page; - } - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); // query params - if ($page_size !== null) { - if ('form' === 'form' && is_array($page_size)) { - foreach ($page_size as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['page_size'] = $page_size; - } - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'page_size', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); // path params if ($team_id !== null) { $resourcePath = str_replace( - '{' . 'team_id' . '}', + '{team_id}', ObjectSerializer::toPathValue($team_id), $resourcePath ); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -2217,18 +2353,19 @@ public function teamMembersRequest(string $team_id, int $page = 1, int $page_siz // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -2252,11 +2389,11 @@ public function teamMembersRequest(string $team_id, int $page = 1, int $page_siz $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'GET', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -2269,14 +2406,13 @@ public function teamMembersRequest(string $team_id, int $page = 1, int $page_siz * * @param Model\TeamRemoveMemberRequest $team_remove_member_request team_remove_member_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\TeamGetResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function teamRemoveMember(Model\TeamRemoveMemberRequest $team_remove_member_request) { list($response) = $this->teamRemoveMemberWithHttpInfo($team_remove_member_request); - return $response; } @@ -2286,14 +2422,16 @@ public function teamRemoveMember(Model\TeamRemoveMemberRequest $team_remove_memb * Remove User from Team * * @param Model\TeamRemoveMemberRequest $team_remove_member_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamRemoveMember'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\TeamGetResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::teamRemoveMember. This method will eventually become unavailable */ - public function teamRemoveMemberWithHttpInfo(Model\TeamRemoveMemberRequest $team_remove_member_request) + public function teamRemoveMemberWithHttpInfo(Model\TeamRemoveMemberRequest $team_remove_member_request, string $contentType = self::contentTypes['teamRemoveMember'][0]) { - $request = $this->teamRemoveMemberRequest($team_remove_member_request); + $request = $this->teamRemoveMemberRequest($team_remove_member_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -2303,14 +2441,14 @@ public function teamRemoveMemberWithHttpInfo(Model\TeamRemoveMemberRequest $team } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -2323,51 +2461,73 @@ public function teamRemoveMemberWithHttpInfo(Model\TeamRemoveMemberRequest $team sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 201) { - if ('\Dropbox\Sign\Model\TeamGetResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TeamGetResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 201: + if ('\Dropbox\Sign\Model\TeamGetResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\TeamGetResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TeamGetResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\TeamGetResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -2376,28 +2536,19 @@ public function teamRemoveMemberWithHttpInfo(Model\TeamRemoveMemberRequest $team $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 201) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\TeamGetResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 201: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\TeamGetResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -2408,13 +2559,15 @@ public function teamRemoveMemberWithHttpInfo(Model\TeamRemoveMemberRequest $team * Remove User from Team * * @param Model\TeamRemoveMemberRequest $team_remove_member_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamRemoveMember'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::teamRemoveMember. This method will eventually become unavailable */ - public function teamRemoveMemberAsync(Model\TeamRemoveMemberRequest $team_remove_member_request) + public function teamRemoveMemberAsync(Model\TeamRemoveMemberRequest $team_remove_member_request, string $contentType = self::contentTypes['teamRemoveMember'][0]) { - return $this->teamRemoveMemberAsyncWithHttpInfo($team_remove_member_request) + return $this->teamRemoveMemberAsyncWithHttpInfo($team_remove_member_request, $contentType) ->then( function ($response) { return $response[0]; @@ -2428,23 +2581,28 @@ function ($response) { * Remove User from Team * * @param Model\TeamRemoveMemberRequest $team_remove_member_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamRemoveMember'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::teamRemoveMember. This method will eventually become unavailable */ - public function teamRemoveMemberAsyncWithHttpInfo(Model\TeamRemoveMemberRequest $team_remove_member_request) + public function teamRemoveMemberAsyncWithHttpInfo(Model\TeamRemoveMemberRequest $team_remove_member_request, string $contentType = self::contentTypes['teamRemoveMember'][0]) { $returnType = '\Dropbox\Sign\Model\TeamGetResponse'; - $request = $this->teamRemoveMemberRequest($team_remove_member_request); + $request = $this->teamRemoveMemberRequest($team_remove_member_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -2464,7 +2622,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -2474,11 +2632,13 @@ function ($exception) { * Create request for operation 'teamRemoveMember' * * @param Model\TeamRemoveMemberRequest $team_remove_member_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamRemoveMember'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::teamRemoveMember. This method will eventually become unavailable */ - public function teamRemoveMemberRequest(Model\TeamRemoveMemberRequest $team_remove_member_request) + public function teamRemoveMemberRequest(Model\TeamRemoveMemberRequest $team_remove_member_request, string $contentType = self::contentTypes['teamRemoveMember'][0]) { // verify the required parameter 'team_remove_member_request' is set if ($team_remove_member_request === null || (is_array($team_remove_member_request) && count($team_remove_member_request) === 0)) { @@ -2488,9 +2648,11 @@ public function teamRemoveMemberRequest(Model\TeamRemoveMemberRequest $team_remo } $resourcePath = '/team/remove_member'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $team_remove_member_request @@ -2498,21 +2660,17 @@ public function teamRemoveMemberRequest(Model\TeamRemoveMemberRequest $team_remo $multipart = !empty($formParams); - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($team_remove_member_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($team_remove_member_request)); } else { $httpBody = $team_remove_member_request; } @@ -2531,22 +2689,22 @@ public function teamRemoveMemberRequest(Model\TeamRemoveMemberRequest $team_remo // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $team_remove_member_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -2570,11 +2728,11 @@ public function teamRemoveMemberRequest(Model\TeamRemoveMemberRequest $team_remo $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -2585,18 +2743,17 @@ public function teamRemoveMemberRequest(Model\TeamRemoveMemberRequest $team_remo * * List Sub Teams * - * @param string $team_id The id of the parent Team. (required) - * @param int $page Which page number of the SubTeam List to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $team_id The id of the parent Team. (required) + * @param int $page Which page number of the SubTeam List to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\TeamSubTeamsResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function teamSubTeams(string $team_id, int $page = 1, int $page_size = 20) { list($response) = $this->teamSubTeamsWithHttpInfo($team_id, $page, $page_size); - return $response; } @@ -2605,17 +2762,19 @@ public function teamSubTeams(string $team_id, int $page = 1, int $page_size = 20 * * List Sub Teams * - * @param string $team_id The id of the parent Team. (required) - * @param int $page Which page number of the SubTeam List to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $team_id The id of the parent Team. (required) + * @param int $page Which page number of the SubTeam List to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamSubTeams'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\TeamSubTeamsResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::teamSubTeams. This method will eventually become unavailable */ - public function teamSubTeamsWithHttpInfo(string $team_id, int $page = 1, int $page_size = 20) + public function teamSubTeamsWithHttpInfo(string $team_id, int $page = 1, int $page_size = 20, string $contentType = self::contentTypes['teamSubTeams'][0]) { - $request = $this->teamSubTeamsRequest($team_id, $page, $page_size); + $request = $this->teamSubTeamsRequest($team_id, $page, $page_size, $contentType); try { $options = $this->createHttpClientOption(); @@ -2625,14 +2784,14 @@ public function teamSubTeamsWithHttpInfo(string $team_id, int $page = 1, int $pa } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -2645,51 +2804,73 @@ public function teamSubTeamsWithHttpInfo(string $team_id, int $page = 1, int $pa sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\TeamSubTeamsResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TeamSubTeamsResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\TeamSubTeamsResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\TeamSubTeamsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TeamSubTeamsResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\TeamSubTeamsResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -2698,28 +2879,19 @@ public function teamSubTeamsWithHttpInfo(string $team_id, int $page = 1, int $pa $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\TeamSubTeamsResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\TeamSubTeamsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -2729,16 +2901,18 @@ public function teamSubTeamsWithHttpInfo(string $team_id, int $page = 1, int $pa * * List Sub Teams * - * @param string $team_id The id of the parent Team. (required) - * @param int $page Which page number of the SubTeam List to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $team_id The id of the parent Team. (required) + * @param int $page Which page number of the SubTeam List to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamSubTeams'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::teamSubTeams. This method will eventually become unavailable */ - public function teamSubTeamsAsync(string $team_id, int $page = 1, int $page_size = 20) + public function teamSubTeamsAsync(string $team_id, int $page = 1, int $page_size = 20, string $contentType = self::contentTypes['teamSubTeams'][0]) { - return $this->teamSubTeamsAsyncWithHttpInfo($team_id, $page, $page_size) + return $this->teamSubTeamsAsyncWithHttpInfo($team_id, $page, $page_size, $contentType) ->then( function ($response) { return $response[0]; @@ -2751,26 +2925,31 @@ function ($response) { * * List Sub Teams * - * @param string $team_id The id of the parent Team. (required) - * @param int $page Which page number of the SubTeam List to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $team_id The id of the parent Team. (required) + * @param int $page Which page number of the SubTeam List to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamSubTeams'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::teamSubTeams. This method will eventually become unavailable */ - public function teamSubTeamsAsyncWithHttpInfo(string $team_id, int $page = 1, int $page_size = 20) + public function teamSubTeamsAsyncWithHttpInfo(string $team_id, int $page = 1, int $page_size = 20, string $contentType = self::contentTypes['teamSubTeams'][0]) { $returnType = '\Dropbox\Sign\Model\TeamSubTeamsResponse'; - $request = $this->teamSubTeamsRequest($team_id, $page, $page_size); + $request = $this->teamSubTeamsRequest($team_id, $page, $page_size, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -2790,7 +2969,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -2799,14 +2978,16 @@ function ($exception) { /** * Create request for operation 'teamSubTeams' * - * @param string $team_id The id of the parent Team. (required) - * @param int $page Which page number of the SubTeam List to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $team_id The id of the parent Team. (required) + * @param int $page Which page number of the SubTeam List to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamSubTeams'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::teamSubTeams. This method will eventually become unavailable */ - public function teamSubTeamsRequest(string $team_id, int $page = 1, int $page_size = 20) + public function teamSubTeamsRequest(string $team_id, int $page = 1, int $page_size = 20, string $contentType = self::contentTypes['teamSubTeams'][0]) { // verify the required parameter 'team_id' is set if ($team_id === null || (is_array($team_id) && count($team_id) === 0)) { @@ -2814,6 +2995,7 @@ public function teamSubTeamsRequest(string $team_id, int $page = 1, int $page_si 'Missing the required parameter $team_id when calling teamSubTeams' ); } + if ($page_size !== null && $page_size > 100) { throw new InvalidArgumentException('invalid value for "$page_size" when calling TeamApi.teamSubTeams, must be smaller than or equal to 100.'); } @@ -2822,53 +3004,45 @@ public function teamSubTeamsRequest(string $team_id, int $page = 1, int $page_si } $resourcePath = '/team/sub_teams/{team_id}'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // query params - if ($page !== null) { - if ('form' === 'form' && is_array($page)) { - foreach ($page as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['page'] = $page; - } - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); // query params - if ($page_size !== null) { - if ('form' === 'form' && is_array($page_size)) { - foreach ($page_size as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['page_size'] = $page_size; - } - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'page_size', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); // path params if ($team_id !== null) { $resourcePath = str_replace( - '{' . 'team_id' . '}', + '{team_id}', ObjectSerializer::toPathValue($team_id), $resourcePath ); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -2886,18 +3060,19 @@ public function teamSubTeamsRequest(string $team_id, int $page = 1, int $page_si // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -2921,11 +3096,11 @@ public function teamSubTeamsRequest(string $team_id, int $page = 1, int $page_si $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'GET', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -2938,14 +3113,13 @@ public function teamSubTeamsRequest(string $team_id, int $page = 1, int $page_si * * @param Model\TeamUpdateRequest $team_update_request team_update_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\TeamGetResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function teamUpdate(Model\TeamUpdateRequest $team_update_request) { list($response) = $this->teamUpdateWithHttpInfo($team_update_request); - return $response; } @@ -2955,14 +3129,16 @@ public function teamUpdate(Model\TeamUpdateRequest $team_update_request) * Update Team * * @param Model\TeamUpdateRequest $team_update_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamUpdate'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\TeamGetResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::teamUpdate. This method will eventually become unavailable */ - public function teamUpdateWithHttpInfo(Model\TeamUpdateRequest $team_update_request) + public function teamUpdateWithHttpInfo(Model\TeamUpdateRequest $team_update_request, string $contentType = self::contentTypes['teamUpdate'][0]) { - $request = $this->teamUpdateRequest($team_update_request); + $request = $this->teamUpdateRequest($team_update_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -2972,14 +3148,14 @@ public function teamUpdateWithHttpInfo(Model\TeamUpdateRequest $team_update_requ } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -2992,51 +3168,73 @@ public function teamUpdateWithHttpInfo(Model\TeamUpdateRequest $team_update_requ sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\TeamGetResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TeamGetResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\TeamGetResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\TeamGetResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TeamGetResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\TeamGetResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -3045,28 +3243,19 @@ public function teamUpdateWithHttpInfo(Model\TeamUpdateRequest $team_update_requ $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\TeamGetResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\TeamGetResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -3077,13 +3266,15 @@ public function teamUpdateWithHttpInfo(Model\TeamUpdateRequest $team_update_requ * Update Team * * @param Model\TeamUpdateRequest $team_update_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamUpdate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::teamUpdate. This method will eventually become unavailable */ - public function teamUpdateAsync(Model\TeamUpdateRequest $team_update_request) + public function teamUpdateAsync(Model\TeamUpdateRequest $team_update_request, string $contentType = self::contentTypes['teamUpdate'][0]) { - return $this->teamUpdateAsyncWithHttpInfo($team_update_request) + return $this->teamUpdateAsyncWithHttpInfo($team_update_request, $contentType) ->then( function ($response) { return $response[0]; @@ -3097,23 +3288,28 @@ function ($response) { * Update Team * * @param Model\TeamUpdateRequest $team_update_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamUpdate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::teamUpdate. This method will eventually become unavailable */ - public function teamUpdateAsyncWithHttpInfo(Model\TeamUpdateRequest $team_update_request) + public function teamUpdateAsyncWithHttpInfo(Model\TeamUpdateRequest $team_update_request, string $contentType = self::contentTypes['teamUpdate'][0]) { $returnType = '\Dropbox\Sign\Model\TeamGetResponse'; - $request = $this->teamUpdateRequest($team_update_request); + $request = $this->teamUpdateRequest($team_update_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -3133,7 +3329,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -3143,11 +3339,13 @@ function ($exception) { * Create request for operation 'teamUpdate' * * @param Model\TeamUpdateRequest $team_update_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['teamUpdate'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::teamUpdate. This method will eventually become unavailable */ - public function teamUpdateRequest(Model\TeamUpdateRequest $team_update_request) + public function teamUpdateRequest(Model\TeamUpdateRequest $team_update_request, string $contentType = self::contentTypes['teamUpdate'][0]) { // verify the required parameter 'team_update_request' is set if ($team_update_request === null || (is_array($team_update_request) && count($team_update_request) === 0)) { @@ -3157,9 +3355,11 @@ public function teamUpdateRequest(Model\TeamUpdateRequest $team_update_request) } $resourcePath = '/team'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $team_update_request @@ -3167,21 +3367,17 @@ public function teamUpdateRequest(Model\TeamUpdateRequest $team_update_request) $multipart = !empty($formParams); - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($team_update_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($team_update_request)); } else { $httpBody = $team_update_request; } @@ -3200,22 +3396,22 @@ public function teamUpdateRequest(Model\TeamUpdateRequest $team_update_request) // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $team_update_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -3239,11 +3435,11 @@ public function teamUpdateRequest(Model\TeamUpdateRequest $team_update_request) $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'PUT', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -3252,8 +3448,8 @@ public function teamUpdateRequest(Model\TeamUpdateRequest $team_update_request) /** * Create http client option * - * @throws RuntimeException on file opening failure * @return array of http client options + * @throws RuntimeException on file opening failure */ protected function createHttpClientOption() { @@ -3267,4 +3463,66 @@ protected function createHttpClientOption() return $options; } + + /** + * @return object|array|null + */ + private function handleRangeCodeResponse( + ResponseInterface $response, + string $rangeCode, + string $returnDataType + ) { + $statusCode = $response->getStatusCode(); + $rangeCodeLeft = (int)(substr($rangeCode, 0, 1) . '00'); + $rangeCodeRight = (int)(substr($rangeCode, 0, 1) . '99'); + + if ( + $statusCode < $rangeCodeLeft + || $statusCode > $rangeCodeRight + ) { + return null; + } + + if ($returnDataType === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + } + + return [ + ObjectSerializer::deserialize($content, $returnDataType, []), + $statusCode, + $response->getHeaders(), + ]; + } + + /** + * @return object|array|null + */ + private function handleRangeCodeException( + ApiException $e, + string $rangeCode, + string $exceptionDataType + ): bool { + $statusCode = $e->getCode(); + $rangeCodeLeft = (int)(substr($rangeCode, 0, 1) . '00'); + $rangeCodeRight = (int)(substr($rangeCode, 0, 1) . '99'); + + if ( + $statusCode < $rangeCodeLeft + || $statusCode > $rangeCodeRight + ) { + return false; + } + + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + $exceptionDataType, + $e->getResponseHeaders() + ); + + $e->setResponseObject($data); + + return true; + } } diff --git a/sdks/php/src/Api/TemplateApi.php b/sdks/php/src/Api/TemplateApi.php index 92f2406b5..6b356fc7b 100644 --- a/sdks/php/src/Api/TemplateApi.php +++ b/sdks/php/src/Api/TemplateApi.php @@ -4,7 +4,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -16,7 +15,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -36,11 +35,11 @@ use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Promise; -use GuzzleHttp\Psr7; +use GuzzleHttp\Psr7\MultipartStream; +use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; -use GuzzleHttp\Utils; use InvalidArgumentException; +use JsonException; use Psr\Http\Message\ResponseInterface; use RuntimeException; use SplFileObject; @@ -49,34 +48,65 @@ * TemplateApi Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ class TemplateApi { - /** - * @var ClientInterface - */ + /** @var ClientInterface */ protected $client; - /** - * @var Configuration - */ + /** @var Configuration */ protected $config; - /** - * @var HeaderSelector - */ + /** @var HeaderSelector */ protected $headerSelector; - /** - * @var int Host index - */ + /** @var int Host index */ protected $hostIndex; /** - * @var ResponseInterface|null - */ + * @var string[] * + */ + public const contentTypes = [ + 'templateAddUser' => [ + 'application/json', + ], + 'templateCreate' => [ + 'application/json', + 'multipart/form-data', + ], + 'templateCreateEmbeddedDraft' => [ + 'application/json', + 'multipart/form-data', + ], + 'templateDelete' => [ + 'application/json', + ], + 'templateFiles' => [ + 'application/json', + ], + 'templateFilesAsDataUri' => [ + 'application/json', + ], + 'templateFilesAsFileUrl' => [ + 'application/json', + ], + 'templateGet' => [ + 'application/json', + ], + 'templateList' => [ + 'application/json', + ], + 'templateRemoveUser' => [ + 'application/json', + ], + 'templateUpdateFiles' => [ + 'application/json', + 'multipart/form-data', + ], + ]; + + /** @var ResponseInterface|null */ protected $response; /** @@ -98,6 +128,7 @@ public function __construct( * Set the host index * * @param int $hostIndex Host index (required) + * @deprecated To be made private in the future */ public function setHostIndex(int $hostIndex): void { @@ -108,6 +139,7 @@ public function setHostIndex(int $hostIndex): void * Get the host index * * @return int Host index + * @deprecated To be made private in the future */ public function getHostIndex() { @@ -135,17 +167,16 @@ public function getResponse() * * Add User to Template * - * @param string $template_id The id of the Template to give the Account access to. (required) + * @param string $template_id The id of the Template to give the Account access to. (required) * @param Model\TemplateAddUserRequest $template_add_user_request template_add_user_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\TemplateGetResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function templateAddUser(string $template_id, Model\TemplateAddUserRequest $template_add_user_request) { list($response) = $this->templateAddUserWithHttpInfo($template_id, $template_add_user_request); - return $response; } @@ -154,16 +185,18 @@ public function templateAddUser(string $template_id, Model\TemplateAddUserReques * * Add User to Template * - * @param string $template_id The id of the Template to give the Account access to. (required) + * @param string $template_id The id of the Template to give the Account access to. (required) * @param Model\TemplateAddUserRequest $template_add_user_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateAddUser'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\TemplateGetResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::templateAddUser. This method will eventually become unavailable */ - public function templateAddUserWithHttpInfo(string $template_id, Model\TemplateAddUserRequest $template_add_user_request) + public function templateAddUserWithHttpInfo(string $template_id, Model\TemplateAddUserRequest $template_add_user_request, string $contentType = self::contentTypes['templateAddUser'][0]) { - $request = $this->templateAddUserRequest($template_id, $template_add_user_request); + $request = $this->templateAddUserRequest($template_id, $template_add_user_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -173,14 +206,14 @@ public function templateAddUserWithHttpInfo(string $template_id, Model\TemplateA } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -193,51 +226,73 @@ public function templateAddUserWithHttpInfo(string $template_id, Model\TemplateA sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\TemplateGetResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TemplateGetResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\TemplateGetResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\TemplateGetResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TemplateGetResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\TemplateGetResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -246,28 +301,19 @@ public function templateAddUserWithHttpInfo(string $template_id, Model\TemplateA $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\TemplateGetResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\TemplateGetResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -277,15 +323,17 @@ public function templateAddUserWithHttpInfo(string $template_id, Model\TemplateA * * Add User to Template * - * @param string $template_id The id of the Template to give the Account access to. (required) + * @param string $template_id The id of the Template to give the Account access to. (required) * @param Model\TemplateAddUserRequest $template_add_user_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateAddUser'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::templateAddUser. This method will eventually become unavailable */ - public function templateAddUserAsync(string $template_id, Model\TemplateAddUserRequest $template_add_user_request) + public function templateAddUserAsync(string $template_id, Model\TemplateAddUserRequest $template_add_user_request, string $contentType = self::contentTypes['templateAddUser'][0]) { - return $this->templateAddUserAsyncWithHttpInfo($template_id, $template_add_user_request) + return $this->templateAddUserAsyncWithHttpInfo($template_id, $template_add_user_request, $contentType) ->then( function ($response) { return $response[0]; @@ -298,25 +346,30 @@ function ($response) { * * Add User to Template * - * @param string $template_id The id of the Template to give the Account access to. (required) + * @param string $template_id The id of the Template to give the Account access to. (required) * @param Model\TemplateAddUserRequest $template_add_user_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateAddUser'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::templateAddUser. This method will eventually become unavailable */ - public function templateAddUserAsyncWithHttpInfo(string $template_id, Model\TemplateAddUserRequest $template_add_user_request) + public function templateAddUserAsyncWithHttpInfo(string $template_id, Model\TemplateAddUserRequest $template_add_user_request, string $contentType = self::contentTypes['templateAddUser'][0]) { $returnType = '\Dropbox\Sign\Model\TemplateGetResponse'; - $request = $this->templateAddUserRequest($template_id, $template_add_user_request); + $request = $this->templateAddUserRequest($template_id, $template_add_user_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -336,7 +389,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -345,13 +398,15 @@ function ($exception) { /** * Create request for operation 'templateAddUser' * - * @param string $template_id The id of the Template to give the Account access to. (required) + * @param string $template_id The id of the Template to give the Account access to. (required) * @param Model\TemplateAddUserRequest $template_add_user_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateAddUser'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::templateAddUser. This method will eventually become unavailable */ - public function templateAddUserRequest(string $template_id, Model\TemplateAddUserRequest $template_add_user_request) + public function templateAddUserRequest(string $template_id, Model\TemplateAddUserRequest $template_add_user_request, string $contentType = self::contentTypes['templateAddUser'][0]) { // verify the required parameter 'template_id' is set if ($template_id === null || (is_array($template_id) && count($template_id) === 0)) { @@ -359,6 +414,7 @@ public function templateAddUserRequest(string $template_id, Model\TemplateAddUse 'Missing the required parameter $template_id when calling templateAddUser' ); } + // verify the required parameter 'template_add_user_request' is set if ($template_add_user_request === null || (is_array($template_add_user_request) && count($template_add_user_request) === 0)) { throw new InvalidArgumentException( @@ -367,9 +423,11 @@ public function templateAddUserRequest(string $template_id, Model\TemplateAddUse } $resourcePath = '/template/add_user/{template_id}'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $template_add_user_request @@ -380,27 +438,23 @@ public function templateAddUserRequest(string $template_id, Model\TemplateAddUse // path params if ($template_id !== null) { $resourcePath = str_replace( - '{' . 'template_id' . '}', + '{template_id}', ObjectSerializer::toPathValue($template_id), $resourcePath ); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($template_add_user_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($template_add_user_request)); } else { $httpBody = $template_add_user_request; } @@ -419,22 +473,22 @@ public function templateAddUserRequest(string $template_id, Model\TemplateAddUse // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $template_add_user_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -458,11 +512,11 @@ public function templateAddUserRequest(string $template_id, Model\TemplateAddUse $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -475,14 +529,13 @@ public function templateAddUserRequest(string $template_id, Model\TemplateAddUse * * @param Model\TemplateCreateRequest $template_create_request template_create_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\TemplateCreateResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function templateCreate(Model\TemplateCreateRequest $template_create_request) { list($response) = $this->templateCreateWithHttpInfo($template_create_request); - return $response; } @@ -492,14 +545,16 @@ public function templateCreate(Model\TemplateCreateRequest $template_create_requ * Create Template * * @param Model\TemplateCreateRequest $template_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateCreate'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\TemplateCreateResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::templateCreate. This method will eventually become unavailable */ - public function templateCreateWithHttpInfo(Model\TemplateCreateRequest $template_create_request) + public function templateCreateWithHttpInfo(Model\TemplateCreateRequest $template_create_request, string $contentType = self::contentTypes['templateCreate'][0]) { - $request = $this->templateCreateRequest($template_create_request); + $request = $this->templateCreateRequest($template_create_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -509,14 +564,14 @@ public function templateCreateWithHttpInfo(Model\TemplateCreateRequest $template } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -529,51 +584,73 @@ public function templateCreateWithHttpInfo(Model\TemplateCreateRequest $template sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\TemplateCreateResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TemplateCreateResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\TemplateCreateResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\TemplateCreateResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TemplateCreateResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\TemplateCreateResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -582,28 +659,19 @@ public function templateCreateWithHttpInfo(Model\TemplateCreateRequest $template $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\TemplateCreateResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\TemplateCreateResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -614,13 +682,15 @@ public function templateCreateWithHttpInfo(Model\TemplateCreateRequest $template * Create Template * * @param Model\TemplateCreateRequest $template_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateCreate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::templateCreate. This method will eventually become unavailable */ - public function templateCreateAsync(Model\TemplateCreateRequest $template_create_request) + public function templateCreateAsync(Model\TemplateCreateRequest $template_create_request, string $contentType = self::contentTypes['templateCreate'][0]) { - return $this->templateCreateAsyncWithHttpInfo($template_create_request) + return $this->templateCreateAsyncWithHttpInfo($template_create_request, $contentType) ->then( function ($response) { return $response[0]; @@ -634,23 +704,28 @@ function ($response) { * Create Template * * @param Model\TemplateCreateRequest $template_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateCreate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::templateCreate. This method will eventually become unavailable */ - public function templateCreateAsyncWithHttpInfo(Model\TemplateCreateRequest $template_create_request) + public function templateCreateAsyncWithHttpInfo(Model\TemplateCreateRequest $template_create_request, string $contentType = self::contentTypes['templateCreate'][0]) { $returnType = '\Dropbox\Sign\Model\TemplateCreateResponse'; - $request = $this->templateCreateRequest($template_create_request); + $request = $this->templateCreateRequest($template_create_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -670,7 +745,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -680,11 +755,13 @@ function ($exception) { * Create request for operation 'templateCreate' * * @param Model\TemplateCreateRequest $template_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateCreate'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::templateCreate. This method will eventually become unavailable */ - public function templateCreateRequest(Model\TemplateCreateRequest $template_create_request) + public function templateCreateRequest(Model\TemplateCreateRequest $template_create_request, string $contentType = self::contentTypes['templateCreate'][0]) { // verify the required parameter 'template_create_request' is set if ($template_create_request === null || (is_array($template_create_request) && count($template_create_request) === 0)) { @@ -694,9 +771,11 @@ public function templateCreateRequest(Model\TemplateCreateRequest $template_crea } $resourcePath = '/template/create'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $template_create_request @@ -704,21 +783,17 @@ public function templateCreateRequest(Model\TemplateCreateRequest $template_crea $multipart = !empty($formParams); - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json', 'multipart/form-data'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($template_create_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($template_create_request)); } else { $httpBody = $template_create_request; } @@ -737,22 +812,22 @@ public function templateCreateRequest(Model\TemplateCreateRequest $template_crea // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $template_create_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -776,11 +851,11 @@ public function templateCreateRequest(Model\TemplateCreateRequest $template_crea $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -793,14 +868,13 @@ public function templateCreateRequest(Model\TemplateCreateRequest $template_crea * * @param Model\TemplateCreateEmbeddedDraftRequest $template_create_embedded_draft_request template_create_embedded_draft_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\TemplateCreateEmbeddedDraftResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function templateCreateEmbeddedDraft(Model\TemplateCreateEmbeddedDraftRequest $template_create_embedded_draft_request) { list($response) = $this->templateCreateEmbeddedDraftWithHttpInfo($template_create_embedded_draft_request); - return $response; } @@ -810,14 +884,16 @@ public function templateCreateEmbeddedDraft(Model\TemplateCreateEmbeddedDraftReq * Create Embedded Template Draft * * @param Model\TemplateCreateEmbeddedDraftRequest $template_create_embedded_draft_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateCreateEmbeddedDraft'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\TemplateCreateEmbeddedDraftResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::templateCreateEmbeddedDraft. This method will eventually become unavailable */ - public function templateCreateEmbeddedDraftWithHttpInfo(Model\TemplateCreateEmbeddedDraftRequest $template_create_embedded_draft_request) + public function templateCreateEmbeddedDraftWithHttpInfo(Model\TemplateCreateEmbeddedDraftRequest $template_create_embedded_draft_request, string $contentType = self::contentTypes['templateCreateEmbeddedDraft'][0]) { - $request = $this->templateCreateEmbeddedDraftRequest($template_create_embedded_draft_request); + $request = $this->templateCreateEmbeddedDraftRequest($template_create_embedded_draft_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -827,14 +903,14 @@ public function templateCreateEmbeddedDraftWithHttpInfo(Model\TemplateCreateEmbe } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -847,51 +923,73 @@ public function templateCreateEmbeddedDraftWithHttpInfo(Model\TemplateCreateEmbe sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\TemplateCreateEmbeddedDraftResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TemplateCreateEmbeddedDraftResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\TemplateCreateEmbeddedDraftResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\TemplateCreateEmbeddedDraftResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TemplateCreateEmbeddedDraftResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\TemplateCreateEmbeddedDraftResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -900,28 +998,19 @@ public function templateCreateEmbeddedDraftWithHttpInfo(Model\TemplateCreateEmbe $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\TemplateCreateEmbeddedDraftResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\TemplateCreateEmbeddedDraftResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -932,13 +1021,15 @@ public function templateCreateEmbeddedDraftWithHttpInfo(Model\TemplateCreateEmbe * Create Embedded Template Draft * * @param Model\TemplateCreateEmbeddedDraftRequest $template_create_embedded_draft_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateCreateEmbeddedDraft'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::templateCreateEmbeddedDraft. This method will eventually become unavailable */ - public function templateCreateEmbeddedDraftAsync(Model\TemplateCreateEmbeddedDraftRequest $template_create_embedded_draft_request) + public function templateCreateEmbeddedDraftAsync(Model\TemplateCreateEmbeddedDraftRequest $template_create_embedded_draft_request, string $contentType = self::contentTypes['templateCreateEmbeddedDraft'][0]) { - return $this->templateCreateEmbeddedDraftAsyncWithHttpInfo($template_create_embedded_draft_request) + return $this->templateCreateEmbeddedDraftAsyncWithHttpInfo($template_create_embedded_draft_request, $contentType) ->then( function ($response) { return $response[0]; @@ -952,23 +1043,28 @@ function ($response) { * Create Embedded Template Draft * * @param Model\TemplateCreateEmbeddedDraftRequest $template_create_embedded_draft_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateCreateEmbeddedDraft'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::templateCreateEmbeddedDraft. This method will eventually become unavailable */ - public function templateCreateEmbeddedDraftAsyncWithHttpInfo(Model\TemplateCreateEmbeddedDraftRequest $template_create_embedded_draft_request) + public function templateCreateEmbeddedDraftAsyncWithHttpInfo(Model\TemplateCreateEmbeddedDraftRequest $template_create_embedded_draft_request, string $contentType = self::contentTypes['templateCreateEmbeddedDraft'][0]) { $returnType = '\Dropbox\Sign\Model\TemplateCreateEmbeddedDraftResponse'; - $request = $this->templateCreateEmbeddedDraftRequest($template_create_embedded_draft_request); + $request = $this->templateCreateEmbeddedDraftRequest($template_create_embedded_draft_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -988,7 +1084,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -998,11 +1094,13 @@ function ($exception) { * Create request for operation 'templateCreateEmbeddedDraft' * * @param Model\TemplateCreateEmbeddedDraftRequest $template_create_embedded_draft_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateCreateEmbeddedDraft'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::templateCreateEmbeddedDraft. This method will eventually become unavailable */ - public function templateCreateEmbeddedDraftRequest(Model\TemplateCreateEmbeddedDraftRequest $template_create_embedded_draft_request) + public function templateCreateEmbeddedDraftRequest(Model\TemplateCreateEmbeddedDraftRequest $template_create_embedded_draft_request, string $contentType = self::contentTypes['templateCreateEmbeddedDraft'][0]) { // verify the required parameter 'template_create_embedded_draft_request' is set if ($template_create_embedded_draft_request === null || (is_array($template_create_embedded_draft_request) && count($template_create_embedded_draft_request) === 0)) { @@ -1012,9 +1110,11 @@ public function templateCreateEmbeddedDraftRequest(Model\TemplateCreateEmbeddedD } $resourcePath = '/template/create_embedded_draft'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $template_create_embedded_draft_request @@ -1022,21 +1122,17 @@ public function templateCreateEmbeddedDraftRequest(Model\TemplateCreateEmbeddedD $multipart = !empty($formParams); - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json', 'multipart/form-data'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($template_create_embedded_draft_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($template_create_embedded_draft_request)); } else { $httpBody = $template_create_embedded_draft_request; } @@ -1055,22 +1151,22 @@ public function templateCreateEmbeddedDraftRequest(Model\TemplateCreateEmbeddedD // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $template_create_embedded_draft_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -1094,11 +1190,11 @@ public function templateCreateEmbeddedDraftRequest(Model\TemplateCreateEmbeddedD $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1111,9 +1207,8 @@ public function templateCreateEmbeddedDraftRequest(Model\TemplateCreateEmbeddedD * * @param string $template_id The id of the Template to delete. (required) * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException - * @return void */ public function templateDelete(string $template_id) { @@ -1126,14 +1221,16 @@ public function templateDelete(string $template_id) * Delete Template * * @param string $template_id The id of the Template to delete. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateDelete'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::templateDelete. This method will eventually become unavailable */ - public function templateDeleteWithHttpInfo(string $template_id) + public function templateDeleteWithHttpInfo(string $template_id, string $contentType = self::contentTypes['templateDelete'][0]) { - $request = $this->templateDeleteRequest($template_id); + $request = $this->templateDeleteRequest($template_id, $contentType); try { $options = $this->createHttpClientOption(); @@ -1143,14 +1240,14 @@ public function templateDeleteWithHttpInfo(string $template_id) } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -1163,29 +1260,21 @@ public function templateDeleteWithHttpInfo(string $template_id) sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } return [null, $statusCode, $response->getHeaders()]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { } - throw $e; } } @@ -1196,13 +1285,15 @@ public function templateDeleteWithHttpInfo(string $template_id) * Delete Template * * @param string $template_id The id of the Template to delete. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateDelete'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::templateDelete. This method will eventually become unavailable */ - public function templateDeleteAsync(string $template_id) + public function templateDeleteAsync(string $template_id, string $contentType = self::contentTypes['templateDelete'][0]) { - return $this->templateDeleteAsyncWithHttpInfo($template_id) + return $this->templateDeleteAsyncWithHttpInfo($template_id, $contentType) ->then( function ($response) { return $response[0]; @@ -1216,14 +1307,16 @@ function ($response) { * Delete Template * * @param string $template_id The id of the Template to delete. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateDelete'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::templateDelete. This method will eventually become unavailable */ - public function templateDeleteAsyncWithHttpInfo(string $template_id) + public function templateDeleteAsyncWithHttpInfo(string $template_id, string $contentType = self::contentTypes['templateDelete'][0]) { $returnType = ''; - $request = $this->templateDeleteRequest($template_id); + $request = $this->templateDeleteRequest($template_id, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1242,7 +1335,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -1252,11 +1345,13 @@ function ($exception) { * Create request for operation 'templateDelete' * * @param string $template_id The id of the Template to delete. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateDelete'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::templateDelete. This method will eventually become unavailable */ - public function templateDeleteRequest(string $template_id) + public function templateDeleteRequest(string $template_id, string $contentType = self::contentTypes['templateDelete'][0]) { // verify the required parameter 'template_id' is set if ($template_id === null || (is_array($template_id) && count($template_id) === 0)) { @@ -1266,32 +1361,26 @@ public function templateDeleteRequest(string $template_id) } $resourcePath = '/template/delete/{template_id}'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // path params if ($template_id !== null) { $resourcePath = str_replace( - '{' . 'template_id' . '}', + '{template_id}', ObjectSerializer::toPathValue($template_id), $resourcePath ); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -1309,18 +1398,19 @@ public function templateDeleteRequest(string $template_id) // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -1344,11 +1434,11 @@ public function templateDeleteRequest(string $template_id) $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1360,16 +1450,15 @@ public function templateDeleteRequest(string $template_id) * Get Template Files * * @param string $template_id The id of the template files to retrieve. (required) - * @param string $file_type Set to `pdf` for a single merged document or `zip` for a collection of individual documents. (optional) + * @param string $file_type Set to `pdf` for a single merged document or `zip` for a collection of individual documents. (optional) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return SplFileObject + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function templateFiles(string $template_id, string $file_type = null) { list($response) = $this->templateFilesWithHttpInfo($template_id, $file_type); - return $response; } @@ -1379,15 +1468,17 @@ public function templateFiles(string $template_id, string $file_type = null) * Get Template Files * * @param string $template_id The id of the template files to retrieve. (required) - * @param string $file_type Set to `pdf` for a single merged document or `zip` for a collection of individual documents. (optional) + * @param string $file_type Set to `pdf` for a single merged document or `zip` for a collection of individual documents. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateFiles'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of \SplFileObject|\Dropbox\Sign\Model\ErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::templateFiles. This method will eventually become unavailable */ - public function templateFilesWithHttpInfo(string $template_id, string $file_type = null) + public function templateFilesWithHttpInfo(string $template_id, string $file_type = null, string $contentType = self::contentTypes['templateFiles'][0]) { - $request = $this->templateFilesRequest($template_id, $file_type); + $request = $this->templateFilesRequest($template_id, $file_type, $contentType); try { $options = $this->createHttpClientOption(); @@ -1397,14 +1488,14 @@ public function templateFilesWithHttpInfo(string $template_id, string $file_type } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -1417,51 +1508,73 @@ public function templateFilesWithHttpInfo(string $template_id, string $file_type sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\SplFileObject' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\SplFileObject', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\SplFileObject'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -1470,28 +1583,19 @@ public function templateFilesWithHttpInfo(string $template_id, string $file_type $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SplFileObject', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -1502,14 +1606,16 @@ public function templateFilesWithHttpInfo(string $template_id, string $file_type * Get Template Files * * @param string $template_id The id of the template files to retrieve. (required) - * @param string $file_type Set to `pdf` for a single merged document or `zip` for a collection of individual documents. (optional) + * @param string $file_type Set to `pdf` for a single merged document or `zip` for a collection of individual documents. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateFiles'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::templateFiles. This method will eventually become unavailable */ - public function templateFilesAsync(string $template_id, string $file_type = null) + public function templateFilesAsync(string $template_id, string $file_type = null, string $contentType = self::contentTypes['templateFiles'][0]) { - return $this->templateFilesAsyncWithHttpInfo($template_id, $file_type) + return $this->templateFilesAsyncWithHttpInfo($template_id, $file_type, $contentType) ->then( function ($response) { return $response[0]; @@ -1523,24 +1629,29 @@ function ($response) { * Get Template Files * * @param string $template_id The id of the template files to retrieve. (required) - * @param string $file_type Set to `pdf` for a single merged document or `zip` for a collection of individual documents. (optional) + * @param string $file_type Set to `pdf` for a single merged document or `zip` for a collection of individual documents. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateFiles'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::templateFiles. This method will eventually become unavailable */ - public function templateFilesAsyncWithHttpInfo(string $template_id, string $file_type = null) + public function templateFilesAsyncWithHttpInfo(string $template_id, string $file_type = null, string $contentType = self::contentTypes['templateFiles'][0]) { $returnType = '\SplFileObject'; - $request = $this->templateFilesRequest($template_id, $file_type); + $request = $this->templateFilesRequest($template_id, $file_type, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -1560,7 +1671,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -1570,12 +1681,14 @@ function ($exception) { * Create request for operation 'templateFiles' * * @param string $template_id The id of the template files to retrieve. (required) - * @param string $file_type Set to `pdf` for a single merged document or `zip` for a collection of individual documents. (optional) + * @param string $file_type Set to `pdf` for a single merged document or `zip` for a collection of individual documents. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateFiles'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::templateFiles. This method will eventually become unavailable */ - public function templateFilesRequest(string $template_id, string $file_type = null) + public function templateFilesRequest(string $template_id, string $file_type = null, string $contentType = self::contentTypes['templateFiles'][0]) { // verify the required parameter 'template_id' is set if ($template_id === null || (is_array($template_id) && count($template_id) === 0)) { @@ -1585,43 +1698,36 @@ public function templateFilesRequest(string $template_id, string $file_type = nu } $resourcePath = '/template/files/{template_id}'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // query params - if ($file_type !== null) { - if ('form' === 'form' && is_array($file_type)) { - foreach ($file_type as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['file_type'] = $file_type; - } - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $file_type, + 'file_type', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); // path params if ($template_id !== null) { $resourcePath = str_replace( - '{' . 'template_id' . '}', + '{template_id}', ObjectSerializer::toPathValue($template_id), $resourcePath ); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/pdf', 'application/zip', 'application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/pdf', 'application/zip', 'application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -1639,18 +1745,19 @@ public function templateFilesRequest(string $template_id, string $file_type = nu // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -1674,11 +1781,11 @@ public function templateFilesRequest(string $template_id, string $file_type = nu $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'GET', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1691,14 +1798,13 @@ public function templateFilesRequest(string $template_id, string $file_type = nu * * @param string $template_id The id of the template files to retrieve. (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\FileResponseDataUri + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function templateFilesAsDataUri(string $template_id) { list($response) = $this->templateFilesAsDataUriWithHttpInfo($template_id); - return $response; } @@ -1708,14 +1814,16 @@ public function templateFilesAsDataUri(string $template_id) * Get Template Files as Data Uri * * @param string $template_id The id of the template files to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateFilesAsDataUri'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\FileResponseDataUri, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::templateFilesAsDataUri. This method will eventually become unavailable */ - public function templateFilesAsDataUriWithHttpInfo(string $template_id) + public function templateFilesAsDataUriWithHttpInfo(string $template_id, string $contentType = self::contentTypes['templateFilesAsDataUri'][0]) { - $request = $this->templateFilesAsDataUriRequest($template_id); + $request = $this->templateFilesAsDataUriRequest($template_id, $contentType); try { $options = $this->createHttpClientOption(); @@ -1725,14 +1833,14 @@ public function templateFilesAsDataUriWithHttpInfo(string $template_id) } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -1745,51 +1853,73 @@ public function templateFilesAsDataUriWithHttpInfo(string $template_id) sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\FileResponseDataUri' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\FileResponseDataUri', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\FileResponseDataUri' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\FileResponseDataUri' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\FileResponseDataUri', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\FileResponseDataUri'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -1798,28 +1928,19 @@ public function templateFilesAsDataUriWithHttpInfo(string $template_id) $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\FileResponseDataUri', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\FileResponseDataUri', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -1830,13 +1951,15 @@ public function templateFilesAsDataUriWithHttpInfo(string $template_id) * Get Template Files as Data Uri * * @param string $template_id The id of the template files to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateFilesAsDataUri'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::templateFilesAsDataUri. This method will eventually become unavailable */ - public function templateFilesAsDataUriAsync(string $template_id) + public function templateFilesAsDataUriAsync(string $template_id, string $contentType = self::contentTypes['templateFilesAsDataUri'][0]) { - return $this->templateFilesAsDataUriAsyncWithHttpInfo($template_id) + return $this->templateFilesAsDataUriAsyncWithHttpInfo($template_id, $contentType) ->then( function ($response) { return $response[0]; @@ -1850,23 +1973,28 @@ function ($response) { * Get Template Files as Data Uri * * @param string $template_id The id of the template files to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateFilesAsDataUri'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::templateFilesAsDataUri. This method will eventually become unavailable */ - public function templateFilesAsDataUriAsyncWithHttpInfo(string $template_id) + public function templateFilesAsDataUriAsyncWithHttpInfo(string $template_id, string $contentType = self::contentTypes['templateFilesAsDataUri'][0]) { $returnType = '\Dropbox\Sign\Model\FileResponseDataUri'; - $request = $this->templateFilesAsDataUriRequest($template_id); + $request = $this->templateFilesAsDataUriRequest($template_id, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -1886,7 +2014,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -1896,11 +2024,13 @@ function ($exception) { * Create request for operation 'templateFilesAsDataUri' * * @param string $template_id The id of the template files to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateFilesAsDataUri'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::templateFilesAsDataUri. This method will eventually become unavailable */ - public function templateFilesAsDataUriRequest(string $template_id) + public function templateFilesAsDataUriRequest(string $template_id, string $contentType = self::contentTypes['templateFilesAsDataUri'][0]) { // verify the required parameter 'template_id' is set if ($template_id === null || (is_array($template_id) && count($template_id) === 0)) { @@ -1910,32 +2040,26 @@ public function templateFilesAsDataUriRequest(string $template_id) } $resourcePath = '/template/files_as_data_uri/{template_id}'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // path params if ($template_id !== null) { $resourcePath = str_replace( - '{' . 'template_id' . '}', + '{template_id}', ObjectSerializer::toPathValue($template_id), $resourcePath ); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -1953,18 +2077,19 @@ public function templateFilesAsDataUriRequest(string $template_id) // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -1988,11 +2113,11 @@ public function templateFilesAsDataUriRequest(string $template_id) $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'GET', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -2003,17 +2128,16 @@ public function templateFilesAsDataUriRequest(string $template_id) * * Get Template Files as File Url * - * @param string $template_id The id of the template files to retrieve. (required) - * @param int $force_download By default when opening the `file_url` a browser will download the PDF and save it locally. When set to `0` the PDF file will be displayed in the browser. (optional, default to 1) + * @param string $template_id The id of the template files to retrieve. (required) + * @param int $force_download By default when opening the `file_url` a browser will download the PDF and save it locally. When set to `0` the PDF file will be displayed in the browser. (optional, default to 1) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\FileResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function templateFilesAsFileUrl(string $template_id, int $force_download = 1) { list($response) = $this->templateFilesAsFileUrlWithHttpInfo($template_id, $force_download); - return $response; } @@ -2022,16 +2146,18 @@ public function templateFilesAsFileUrl(string $template_id, int $force_download * * Get Template Files as File Url * - * @param string $template_id The id of the template files to retrieve. (required) - * @param int $force_download By default when opening the `file_url` a browser will download the PDF and save it locally. When set to `0` the PDF file will be displayed in the browser. (optional, default to 1) + * @param string $template_id The id of the template files to retrieve. (required) + * @param int $force_download By default when opening the `file_url` a browser will download the PDF and save it locally. When set to `0` the PDF file will be displayed in the browser. (optional, default to 1) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateFilesAsFileUrl'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\FileResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::templateFilesAsFileUrl. This method will eventually become unavailable */ - public function templateFilesAsFileUrlWithHttpInfo(string $template_id, int $force_download = 1) + public function templateFilesAsFileUrlWithHttpInfo(string $template_id, int $force_download = 1, string $contentType = self::contentTypes['templateFilesAsFileUrl'][0]) { - $request = $this->templateFilesAsFileUrlRequest($template_id, $force_download); + $request = $this->templateFilesAsFileUrlRequest($template_id, $force_download, $contentType); try { $options = $this->createHttpClientOption(); @@ -2041,14 +2167,14 @@ public function templateFilesAsFileUrlWithHttpInfo(string $template_id, int $for } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -2061,51 +2187,73 @@ public function templateFilesAsFileUrlWithHttpInfo(string $template_id, int $for sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\FileResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\FileResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\FileResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\FileResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\FileResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\FileResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -2114,28 +2262,19 @@ public function templateFilesAsFileUrlWithHttpInfo(string $template_id, int $for $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\FileResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\FileResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -2145,15 +2284,17 @@ public function templateFilesAsFileUrlWithHttpInfo(string $template_id, int $for * * Get Template Files as File Url * - * @param string $template_id The id of the template files to retrieve. (required) - * @param int $force_download By default when opening the `file_url` a browser will download the PDF and save it locally. When set to `0` the PDF file will be displayed in the browser. (optional, default to 1) + * @param string $template_id The id of the template files to retrieve. (required) + * @param int $force_download By default when opening the `file_url` a browser will download the PDF and save it locally. When set to `0` the PDF file will be displayed in the browser. (optional, default to 1) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateFilesAsFileUrl'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::templateFilesAsFileUrl. This method will eventually become unavailable */ - public function templateFilesAsFileUrlAsync(string $template_id, int $force_download = 1) + public function templateFilesAsFileUrlAsync(string $template_id, int $force_download = 1, string $contentType = self::contentTypes['templateFilesAsFileUrl'][0]) { - return $this->templateFilesAsFileUrlAsyncWithHttpInfo($template_id, $force_download) + return $this->templateFilesAsFileUrlAsyncWithHttpInfo($template_id, $force_download, $contentType) ->then( function ($response) { return $response[0]; @@ -2166,25 +2307,30 @@ function ($response) { * * Get Template Files as File Url * - * @param string $template_id The id of the template files to retrieve. (required) - * @param int $force_download By default when opening the `file_url` a browser will download the PDF and save it locally. When set to `0` the PDF file will be displayed in the browser. (optional, default to 1) + * @param string $template_id The id of the template files to retrieve. (required) + * @param int $force_download By default when opening the `file_url` a browser will download the PDF and save it locally. When set to `0` the PDF file will be displayed in the browser. (optional, default to 1) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateFilesAsFileUrl'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::templateFilesAsFileUrl. This method will eventually become unavailable */ - public function templateFilesAsFileUrlAsyncWithHttpInfo(string $template_id, int $force_download = 1) + public function templateFilesAsFileUrlAsyncWithHttpInfo(string $template_id, int $force_download = 1, string $contentType = self::contentTypes['templateFilesAsFileUrl'][0]) { $returnType = '\Dropbox\Sign\Model\FileResponse'; - $request = $this->templateFilesAsFileUrlRequest($template_id, $force_download); + $request = $this->templateFilesAsFileUrlRequest($template_id, $force_download, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -2204,7 +2350,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -2213,13 +2359,15 @@ function ($exception) { /** * Create request for operation 'templateFilesAsFileUrl' * - * @param string $template_id The id of the template files to retrieve. (required) - * @param int $force_download By default when opening the `file_url` a browser will download the PDF and save it locally. When set to `0` the PDF file will be displayed in the browser. (optional, default to 1) + * @param string $template_id The id of the template files to retrieve. (required) + * @param int $force_download By default when opening the `file_url` a browser will download the PDF and save it locally. When set to `0` the PDF file will be displayed in the browser. (optional, default to 1) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateFilesAsFileUrl'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::templateFilesAsFileUrl. This method will eventually become unavailable */ - public function templateFilesAsFileUrlRequest(string $template_id, int $force_download = 1) + public function templateFilesAsFileUrlRequest(string $template_id, int $force_download = 1, string $contentType = self::contentTypes['templateFilesAsFileUrl'][0]) { // verify the required parameter 'template_id' is set if ($template_id === null || (is_array($template_id) && count($template_id) === 0)) { @@ -2229,43 +2377,36 @@ public function templateFilesAsFileUrlRequest(string $template_id, int $force_do } $resourcePath = '/template/files_as_file_url/{template_id}'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // query params - if ($force_download !== null) { - if ('form' === 'form' && is_array($force_download)) { - foreach ($force_download as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['force_download'] = $force_download; - } - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $force_download, + 'force_download', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); // path params if ($template_id !== null) { $resourcePath = str_replace( - '{' . 'template_id' . '}', + '{template_id}', ObjectSerializer::toPathValue($template_id), $resourcePath ); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -2283,18 +2424,19 @@ public function templateFilesAsFileUrlRequest(string $template_id, int $force_do // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -2318,11 +2460,11 @@ public function templateFilesAsFileUrlRequest(string $template_id, int $force_do $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'GET', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -2335,14 +2477,13 @@ public function templateFilesAsFileUrlRequest(string $template_id, int $force_do * * @param string $template_id The id of the Template to retrieve. (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\TemplateGetResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function templateGet(string $template_id) { list($response) = $this->templateGetWithHttpInfo($template_id); - return $response; } @@ -2352,14 +2493,16 @@ public function templateGet(string $template_id) * Get Template * * @param string $template_id The id of the Template to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateGet'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\TemplateGetResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::templateGet. This method will eventually become unavailable */ - public function templateGetWithHttpInfo(string $template_id) + public function templateGetWithHttpInfo(string $template_id, string $contentType = self::contentTypes['templateGet'][0]) { - $request = $this->templateGetRequest($template_id); + $request = $this->templateGetRequest($template_id, $contentType); try { $options = $this->createHttpClientOption(); @@ -2369,14 +2512,14 @@ public function templateGetWithHttpInfo(string $template_id) } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -2389,51 +2532,73 @@ public function templateGetWithHttpInfo(string $template_id) sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\TemplateGetResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TemplateGetResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\TemplateGetResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\TemplateGetResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TemplateGetResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\TemplateGetResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -2442,28 +2607,19 @@ public function templateGetWithHttpInfo(string $template_id) $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\TemplateGetResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\TemplateGetResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -2474,13 +2630,15 @@ public function templateGetWithHttpInfo(string $template_id) * Get Template * * @param string $template_id The id of the Template to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateGet'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::templateGet. This method will eventually become unavailable */ - public function templateGetAsync(string $template_id) + public function templateGetAsync(string $template_id, string $contentType = self::contentTypes['templateGet'][0]) { - return $this->templateGetAsyncWithHttpInfo($template_id) + return $this->templateGetAsyncWithHttpInfo($template_id, $contentType) ->then( function ($response) { return $response[0]; @@ -2494,23 +2652,28 @@ function ($response) { * Get Template * * @param string $template_id The id of the Template to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateGet'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::templateGet. This method will eventually become unavailable */ - public function templateGetAsyncWithHttpInfo(string $template_id) + public function templateGetAsyncWithHttpInfo(string $template_id, string $contentType = self::contentTypes['templateGet'][0]) { $returnType = '\Dropbox\Sign\Model\TemplateGetResponse'; - $request = $this->templateGetRequest($template_id); + $request = $this->templateGetRequest($template_id, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -2530,7 +2693,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -2540,11 +2703,13 @@ function ($exception) { * Create request for operation 'templateGet' * * @param string $template_id The id of the Template to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateGet'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::templateGet. This method will eventually become unavailable */ - public function templateGetRequest(string $template_id) + public function templateGetRequest(string $template_id, string $contentType = self::contentTypes['templateGet'][0]) { // verify the required parameter 'template_id' is set if ($template_id === null || (is_array($template_id) && count($template_id) === 0)) { @@ -2554,32 +2719,26 @@ public function templateGetRequest(string $template_id) } $resourcePath = '/template/{template_id}'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // path params if ($template_id !== null) { $resourcePath = str_replace( - '{' . 'template_id' . '}', + '{template_id}', ObjectSerializer::toPathValue($template_id), $resourcePath ); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -2597,18 +2756,19 @@ public function templateGetRequest(string $template_id) // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -2632,11 +2792,11 @@ public function templateGetRequest(string $template_id) $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'GET', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -2648,18 +2808,17 @@ public function templateGetRequest(string $template_id) * List Templates * * @param string $account_id Which account to return Templates for. Must be a team member. Use `all` to indicate all team members. Defaults to your account. (optional) - * @param int $page Which page number of the Template List to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) - * @param string $query String that includes search terms and/or fields to be used to filter the Template objects. (optional) + * @param int $page Which page number of the Template List to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $query String that includes search terms and/or fields to be used to filter the Template objects. (optional) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\TemplateListResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function templateList(string $account_id = null, int $page = 1, int $page_size = 20, string $query = null) { list($response) = $this->templateListWithHttpInfo($account_id, $page, $page_size, $query); - return $response; } @@ -2668,18 +2827,20 @@ public function templateList(string $account_id = null, int $page = 1, int $page * * List Templates * - * @param string $account_id Which account to return Templates for. Must be a team member. Use `all` to indicate all team members. Defaults to your account. (optional) - * @param int $page Which page number of the Template List to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) - * @param string $query String that includes search terms and/or fields to be used to filter the Template objects. (optional) + * @param string $account_id Which account to return Templates for. Must be a team member. Use `all` to indicate all team members. Defaults to your account. (optional) + * @param int $page Which page number of the Template List to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $query String that includes search terms and/or fields to be used to filter the Template objects. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateList'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\TemplateListResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::templateList. This method will eventually become unavailable */ - public function templateListWithHttpInfo(string $account_id = null, int $page = 1, int $page_size = 20, string $query = null) + public function templateListWithHttpInfo(string $account_id = null, int $page = 1, int $page_size = 20, string $query = null, string $contentType = self::contentTypes['templateList'][0]) { - $request = $this->templateListRequest($account_id, $page, $page_size, $query); + $request = $this->templateListRequest($account_id, $page, $page_size, $query, $contentType); try { $options = $this->createHttpClientOption(); @@ -2689,14 +2850,14 @@ public function templateListWithHttpInfo(string $account_id = null, int $page = } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -2709,51 +2870,73 @@ public function templateListWithHttpInfo(string $account_id = null, int $page = sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\TemplateListResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TemplateListResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\TemplateListResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\TemplateListResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TemplateListResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\TemplateListResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -2762,28 +2945,19 @@ public function templateListWithHttpInfo(string $account_id = null, int $page = $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\TemplateListResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\TemplateListResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -2793,17 +2967,19 @@ public function templateListWithHttpInfo(string $account_id = null, int $page = * * List Templates * - * @param string $account_id Which account to return Templates for. Must be a team member. Use `all` to indicate all team members. Defaults to your account. (optional) - * @param int $page Which page number of the Template List to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) - * @param string $query String that includes search terms and/or fields to be used to filter the Template objects. (optional) + * @param string $account_id Which account to return Templates for. Must be a team member. Use `all` to indicate all team members. Defaults to your account. (optional) + * @param int $page Which page number of the Template List to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $query String that includes search terms and/or fields to be used to filter the Template objects. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateList'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::templateList. This method will eventually become unavailable */ - public function templateListAsync(string $account_id = null, int $page = 1, int $page_size = 20, string $query = null) + public function templateListAsync(string $account_id = null, int $page = 1, int $page_size = 20, string $query = null, string $contentType = self::contentTypes['templateList'][0]) { - return $this->templateListAsyncWithHttpInfo($account_id, $page, $page_size, $query) + return $this->templateListAsyncWithHttpInfo($account_id, $page, $page_size, $query, $contentType) ->then( function ($response) { return $response[0]; @@ -2816,27 +2992,32 @@ function ($response) { * * List Templates * - * @param string $account_id Which account to return Templates for. Must be a team member. Use `all` to indicate all team members. Defaults to your account. (optional) - * @param int $page Which page number of the Template List to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) - * @param string $query String that includes search terms and/or fields to be used to filter the Template objects. (optional) + * @param string $account_id Which account to return Templates for. Must be a team member. Use `all` to indicate all team members. Defaults to your account. (optional) + * @param int $page Which page number of the Template List to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $query String that includes search terms and/or fields to be used to filter the Template objects. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateList'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::templateList. This method will eventually become unavailable */ - public function templateListAsyncWithHttpInfo(string $account_id = null, int $page = 1, int $page_size = 20, string $query = null) + public function templateListAsyncWithHttpInfo(string $account_id = null, int $page = 1, int $page_size = 20, string $query = null, string $contentType = self::contentTypes['templateList'][0]) { $returnType = '\Dropbox\Sign\Model\TemplateListResponse'; - $request = $this->templateListRequest($account_id, $page, $page_size, $query); + $request = $this->templateListRequest($account_id, $page, $page_size, $query, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -2856,7 +3037,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -2865,15 +3046,17 @@ function ($exception) { /** * Create request for operation 'templateList' * - * @param string $account_id Which account to return Templates for. Must be a team member. Use `all` to indicate all team members. Defaults to your account. (optional) - * @param int $page Which page number of the Template List to return. Defaults to `1`. (optional, default to 1) - * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) - * @param string $query String that includes search terms and/or fields to be used to filter the Template objects. (optional) + * @param string $account_id Which account to return Templates for. Must be a team member. Use `all` to indicate all team members. Defaults to your account. (optional) + * @param int $page Which page number of the Template List to return. Defaults to `1`. (optional, default to 1) + * @param int $page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (optional, default to 20) + * @param string $query String that includes search terms and/or fields to be used to filter the Template objects. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateList'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::templateList. This method will eventually become unavailable */ - public function templateListRequest(string $account_id = null, int $page = 1, int $page_size = 20, string $query = null) + public function templateListRequest(string $account_id = null, int $page = 1, int $page_size = 20, string $query = null, string $contentType = self::contentTypes['templateList'][0]) { if ($page_size !== null && $page_size > 100) { throw new InvalidArgumentException('invalid value for "$page_size" when calling TemplateApi.templateList, must be smaller than or equal to 100.'); @@ -2883,64 +3066,54 @@ public function templateListRequest(string $account_id = null, int $page = 1, in } $resourcePath = '/template/list'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - $formParams = []; $multipart = false; // query params - if ($account_id !== null) { - if ('form' === 'form' && is_array($account_id)) { - foreach ($account_id as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['account_id'] = $account_id; - } - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $account_id, + 'account_id', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); // query params - if ($page !== null) { - if ('form' === 'form' && is_array($page)) { - foreach ($page as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['page'] = $page; - } - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); // query params - if ($page_size !== null) { - if ('form' === 'form' && is_array($page_size)) { - foreach ($page_size as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['page_size'] = $page_size; - } - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'page_size', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); // query params - if ($query !== null) { - if ('form' === 'form' && is_array($query)) { - foreach ($query as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['query'] = $query; - } - } - - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $query, + 'query', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -2958,18 +3131,19 @@ public function templateListRequest(string $account_id = null, int $page = 1, in // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -2993,11 +3167,11 @@ public function templateListRequest(string $account_id = null, int $page = 1, in $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'GET', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -3008,17 +3182,16 @@ public function templateListRequest(string $account_id = null, int $page = 1, in * * Remove User from Template * - * @param string $template_id The id of the Template to remove the Account's access to. (required) + * @param string $template_id The id of the Template to remove the Account's access to. (required) * @param Model\TemplateRemoveUserRequest $template_remove_user_request template_remove_user_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\TemplateGetResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function templateRemoveUser(string $template_id, Model\TemplateRemoveUserRequest $template_remove_user_request) { list($response) = $this->templateRemoveUserWithHttpInfo($template_id, $template_remove_user_request); - return $response; } @@ -3027,16 +3200,18 @@ public function templateRemoveUser(string $template_id, Model\TemplateRemoveUser * * Remove User from Template * - * @param string $template_id The id of the Template to remove the Account's access to. (required) + * @param string $template_id The id of the Template to remove the Account's access to. (required) * @param Model\TemplateRemoveUserRequest $template_remove_user_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateRemoveUser'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\TemplateGetResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::templateRemoveUser. This method will eventually become unavailable */ - public function templateRemoveUserWithHttpInfo(string $template_id, Model\TemplateRemoveUserRequest $template_remove_user_request) + public function templateRemoveUserWithHttpInfo(string $template_id, Model\TemplateRemoveUserRequest $template_remove_user_request, string $contentType = self::contentTypes['templateRemoveUser'][0]) { - $request = $this->templateRemoveUserRequest($template_id, $template_remove_user_request); + $request = $this->templateRemoveUserRequest($template_id, $template_remove_user_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -3046,14 +3221,14 @@ public function templateRemoveUserWithHttpInfo(string $template_id, Model\Templa } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -3066,51 +3241,73 @@ public function templateRemoveUserWithHttpInfo(string $template_id, Model\Templa sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\TemplateGetResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TemplateGetResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\TemplateGetResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\TemplateGetResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TemplateGetResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\TemplateGetResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -3119,28 +3316,19 @@ public function templateRemoveUserWithHttpInfo(string $template_id, Model\Templa $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\TemplateGetResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\TemplateGetResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -3150,15 +3338,17 @@ public function templateRemoveUserWithHttpInfo(string $template_id, Model\Templa * * Remove User from Template * - * @param string $template_id The id of the Template to remove the Account's access to. (required) + * @param string $template_id The id of the Template to remove the Account's access to. (required) * @param Model\TemplateRemoveUserRequest $template_remove_user_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateRemoveUser'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::templateRemoveUser. This method will eventually become unavailable */ - public function templateRemoveUserAsync(string $template_id, Model\TemplateRemoveUserRequest $template_remove_user_request) + public function templateRemoveUserAsync(string $template_id, Model\TemplateRemoveUserRequest $template_remove_user_request, string $contentType = self::contentTypes['templateRemoveUser'][0]) { - return $this->templateRemoveUserAsyncWithHttpInfo($template_id, $template_remove_user_request) + return $this->templateRemoveUserAsyncWithHttpInfo($template_id, $template_remove_user_request, $contentType) ->then( function ($response) { return $response[0]; @@ -3171,25 +3361,30 @@ function ($response) { * * Remove User from Template * - * @param string $template_id The id of the Template to remove the Account's access to. (required) + * @param string $template_id The id of the Template to remove the Account's access to. (required) * @param Model\TemplateRemoveUserRequest $template_remove_user_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateRemoveUser'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::templateRemoveUser. This method will eventually become unavailable */ - public function templateRemoveUserAsyncWithHttpInfo(string $template_id, Model\TemplateRemoveUserRequest $template_remove_user_request) + public function templateRemoveUserAsyncWithHttpInfo(string $template_id, Model\TemplateRemoveUserRequest $template_remove_user_request, string $contentType = self::contentTypes['templateRemoveUser'][0]) { $returnType = '\Dropbox\Sign\Model\TemplateGetResponse'; - $request = $this->templateRemoveUserRequest($template_id, $template_remove_user_request); + $request = $this->templateRemoveUserRequest($template_id, $template_remove_user_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -3209,7 +3404,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -3218,13 +3413,15 @@ function ($exception) { /** * Create request for operation 'templateRemoveUser' * - * @param string $template_id The id of the Template to remove the Account's access to. (required) + * @param string $template_id The id of the Template to remove the Account's access to. (required) * @param Model\TemplateRemoveUserRequest $template_remove_user_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateRemoveUser'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::templateRemoveUser. This method will eventually become unavailable */ - public function templateRemoveUserRequest(string $template_id, Model\TemplateRemoveUserRequest $template_remove_user_request) + public function templateRemoveUserRequest(string $template_id, Model\TemplateRemoveUserRequest $template_remove_user_request, string $contentType = self::contentTypes['templateRemoveUser'][0]) { // verify the required parameter 'template_id' is set if ($template_id === null || (is_array($template_id) && count($template_id) === 0)) { @@ -3232,6 +3429,7 @@ public function templateRemoveUserRequest(string $template_id, Model\TemplateRem 'Missing the required parameter $template_id when calling templateRemoveUser' ); } + // verify the required parameter 'template_remove_user_request' is set if ($template_remove_user_request === null || (is_array($template_remove_user_request) && count($template_remove_user_request) === 0)) { throw new InvalidArgumentException( @@ -3240,9 +3438,11 @@ public function templateRemoveUserRequest(string $template_id, Model\TemplateRem } $resourcePath = '/template/remove_user/{template_id}'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $template_remove_user_request @@ -3253,27 +3453,23 @@ public function templateRemoveUserRequest(string $template_id, Model\TemplateRem // path params if ($template_id !== null) { $resourcePath = str_replace( - '{' . 'template_id' . '}', + '{template_id}', ObjectSerializer::toPathValue($template_id), $resourcePath ); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($template_remove_user_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($template_remove_user_request)); } else { $httpBody = $template_remove_user_request; } @@ -3292,22 +3488,22 @@ public function templateRemoveUserRequest(string $template_id, Model\TemplateRem // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $template_remove_user_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -3331,11 +3527,11 @@ public function templateRemoveUserRequest(string $template_id, Model\TemplateRem $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -3346,17 +3542,16 @@ public function templateRemoveUserRequest(string $template_id, Model\TemplateRem * * Update Template Files * - * @param string $template_id The ID of the template whose files to update. (required) + * @param string $template_id The ID of the template whose files to update. (required) * @param Model\TemplateUpdateFilesRequest $template_update_files_request template_update_files_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\TemplateUpdateFilesResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function templateUpdateFiles(string $template_id, Model\TemplateUpdateFilesRequest $template_update_files_request) { list($response) = $this->templateUpdateFilesWithHttpInfo($template_id, $template_update_files_request); - return $response; } @@ -3365,16 +3560,18 @@ public function templateUpdateFiles(string $template_id, Model\TemplateUpdateFil * * Update Template Files * - * @param string $template_id The ID of the template whose files to update. (required) + * @param string $template_id The ID of the template whose files to update. (required) * @param Model\TemplateUpdateFilesRequest $template_update_files_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateUpdateFiles'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\TemplateUpdateFilesResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::templateUpdateFiles. This method will eventually become unavailable */ - public function templateUpdateFilesWithHttpInfo(string $template_id, Model\TemplateUpdateFilesRequest $template_update_files_request) + public function templateUpdateFilesWithHttpInfo(string $template_id, Model\TemplateUpdateFilesRequest $template_update_files_request, string $contentType = self::contentTypes['templateUpdateFiles'][0]) { - $request = $this->templateUpdateFilesRequest($template_id, $template_update_files_request); + $request = $this->templateUpdateFilesRequest($template_id, $template_update_files_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -3384,14 +3581,14 @@ public function templateUpdateFilesWithHttpInfo(string $template_id, Model\Templ } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -3404,51 +3601,73 @@ public function templateUpdateFilesWithHttpInfo(string $template_id, Model\Templ sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\TemplateUpdateFilesResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TemplateUpdateFilesResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\TemplateUpdateFilesResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\TemplateUpdateFilesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\TemplateUpdateFilesResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\TemplateUpdateFilesResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -3457,28 +3676,19 @@ public function templateUpdateFilesWithHttpInfo(string $template_id, Model\Templ $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\TemplateUpdateFilesResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; + } + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\TemplateUpdateFilesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -3488,15 +3698,17 @@ public function templateUpdateFilesWithHttpInfo(string $template_id, Model\Templ * * Update Template Files * - * @param string $template_id The ID of the template whose files to update. (required) + * @param string $template_id The ID of the template whose files to update. (required) * @param Model\TemplateUpdateFilesRequest $template_update_files_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateUpdateFiles'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::templateUpdateFiles. This method will eventually become unavailable */ - public function templateUpdateFilesAsync(string $template_id, Model\TemplateUpdateFilesRequest $template_update_files_request) + public function templateUpdateFilesAsync(string $template_id, Model\TemplateUpdateFilesRequest $template_update_files_request, string $contentType = self::contentTypes['templateUpdateFiles'][0]) { - return $this->templateUpdateFilesAsyncWithHttpInfo($template_id, $template_update_files_request) + return $this->templateUpdateFilesAsyncWithHttpInfo($template_id, $template_update_files_request, $contentType) ->then( function ($response) { return $response[0]; @@ -3509,25 +3721,30 @@ function ($response) { * * Update Template Files * - * @param string $template_id The ID of the template whose files to update. (required) + * @param string $template_id The ID of the template whose files to update. (required) * @param Model\TemplateUpdateFilesRequest $template_update_files_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateUpdateFiles'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::templateUpdateFiles. This method will eventually become unavailable */ - public function templateUpdateFilesAsyncWithHttpInfo(string $template_id, Model\TemplateUpdateFilesRequest $template_update_files_request) + public function templateUpdateFilesAsyncWithHttpInfo(string $template_id, Model\TemplateUpdateFilesRequest $template_update_files_request, string $contentType = self::contentTypes['templateUpdateFiles'][0]) { $returnType = '\Dropbox\Sign\Model\TemplateUpdateFilesResponse'; - $request = $this->templateUpdateFilesRequest($template_id, $template_update_files_request); + $request = $this->templateUpdateFilesRequest($template_id, $template_update_files_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -3547,7 +3764,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -3556,13 +3773,15 @@ function ($exception) { /** * Create request for operation 'templateUpdateFiles' * - * @param string $template_id The ID of the template whose files to update. (required) + * @param string $template_id The ID of the template whose files to update. (required) * @param Model\TemplateUpdateFilesRequest $template_update_files_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['templateUpdateFiles'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::templateUpdateFiles. This method will eventually become unavailable */ - public function templateUpdateFilesRequest(string $template_id, Model\TemplateUpdateFilesRequest $template_update_files_request) + public function templateUpdateFilesRequest(string $template_id, Model\TemplateUpdateFilesRequest $template_update_files_request, string $contentType = self::contentTypes['templateUpdateFiles'][0]) { // verify the required parameter 'template_id' is set if ($template_id === null || (is_array($template_id) && count($template_id) === 0)) { @@ -3570,6 +3789,7 @@ public function templateUpdateFilesRequest(string $template_id, Model\TemplateUp 'Missing the required parameter $template_id when calling templateUpdateFiles' ); } + // verify the required parameter 'template_update_files_request' is set if ($template_update_files_request === null || (is_array($template_update_files_request) && count($template_update_files_request) === 0)) { throw new InvalidArgumentException( @@ -3578,9 +3798,11 @@ public function templateUpdateFilesRequest(string $template_id, Model\TemplateUp } $resourcePath = '/template/update_files/{template_id}'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $template_update_files_request @@ -3591,27 +3813,23 @@ public function templateUpdateFilesRequest(string $template_id, Model\TemplateUp // path params if ($template_id !== null) { $resourcePath = str_replace( - '{' . 'template_id' . '}', + '{template_id}', ObjectSerializer::toPathValue($template_id), $resourcePath ); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json', 'multipart/form-data'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($template_update_files_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($template_update_files_request)); } else { $httpBody = $template_update_files_request; } @@ -3630,22 +3848,22 @@ public function templateUpdateFilesRequest(string $template_id, Model\TemplateUp // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $template_update_files_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -3669,11 +3887,11 @@ public function templateUpdateFilesRequest(string $template_id, Model\TemplateUp $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -3682,8 +3900,8 @@ public function templateUpdateFilesRequest(string $template_id, Model\TemplateUp /** * Create http client option * - * @throws RuntimeException on file opening failure * @return array of http client options + * @throws RuntimeException on file opening failure */ protected function createHttpClientOption() { @@ -3697,4 +3915,66 @@ protected function createHttpClientOption() return $options; } + + /** + * @return object|array|null + */ + private function handleRangeCodeResponse( + ResponseInterface $response, + string $rangeCode, + string $returnDataType + ) { + $statusCode = $response->getStatusCode(); + $rangeCodeLeft = (int)(substr($rangeCode, 0, 1) . '00'); + $rangeCodeRight = (int)(substr($rangeCode, 0, 1) . '99'); + + if ( + $statusCode < $rangeCodeLeft + || $statusCode > $rangeCodeRight + ) { + return null; + } + + if ($returnDataType === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + } + + return [ + ObjectSerializer::deserialize($content, $returnDataType, []), + $statusCode, + $response->getHeaders(), + ]; + } + + /** + * @return object|array|null + */ + private function handleRangeCodeException( + ApiException $e, + string $rangeCode, + string $exceptionDataType + ): bool { + $statusCode = $e->getCode(); + $rangeCodeLeft = (int)(substr($rangeCode, 0, 1) . '00'); + $rangeCodeRight = (int)(substr($rangeCode, 0, 1) . '99'); + + if ( + $statusCode < $rangeCodeLeft + || $statusCode > $rangeCodeRight + ) { + return false; + } + + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + $exceptionDataType, + $e->getResponseHeaders() + ); + + $e->setResponseObject($data); + + return true; + } } diff --git a/sdks/php/src/Api/UnclaimedDraftApi.php b/sdks/php/src/Api/UnclaimedDraftApi.php index a83572a10..3886a87c5 100644 --- a/sdks/php/src/Api/UnclaimedDraftApi.php +++ b/sdks/php/src/Api/UnclaimedDraftApi.php @@ -4,7 +4,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -16,7 +15,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -36,11 +35,11 @@ use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Promise; -use GuzzleHttp\Psr7; +use GuzzleHttp\Psr7\MultipartStream; +use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; -use GuzzleHttp\Utils; use InvalidArgumentException; +use JsonException; use Psr\Http\Message\ResponseInterface; use RuntimeException; @@ -48,34 +47,44 @@ * UnclaimedDraftApi Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ class UnclaimedDraftApi { - /** - * @var ClientInterface - */ + /** @var ClientInterface */ protected $client; - /** - * @var Configuration - */ + /** @var Configuration */ protected $config; - /** - * @var HeaderSelector - */ + /** @var HeaderSelector */ protected $headerSelector; - /** - * @var int Host index - */ + /** @var int Host index */ protected $hostIndex; /** - * @var ResponseInterface|null + * @var string[] * */ + public const contentTypes = [ + 'unclaimedDraftCreate' => [ + 'application/json', + 'multipart/form-data', + ], + 'unclaimedDraftCreateEmbedded' => [ + 'application/json', + 'multipart/form-data', + ], + 'unclaimedDraftCreateEmbeddedWithTemplate' => [ + 'application/json', + 'multipart/form-data', + ], + 'unclaimedDraftEditAndResend' => [ + 'application/json', + ], + ]; + + /** @var ResponseInterface|null */ protected $response; /** @@ -97,6 +106,7 @@ public function __construct( * Set the host index * * @param int $hostIndex Host index (required) + * @deprecated To be made private in the future */ public function setHostIndex(int $hostIndex): void { @@ -107,6 +117,7 @@ public function setHostIndex(int $hostIndex): void * Get the host index * * @return int Host index + * @deprecated To be made private in the future */ public function getHostIndex() { @@ -136,14 +147,13 @@ public function getResponse() * * @param Model\UnclaimedDraftCreateRequest $unclaimed_draft_create_request unclaimed_draft_create_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\UnclaimedDraftCreateResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function unclaimedDraftCreate(Model\UnclaimedDraftCreateRequest $unclaimed_draft_create_request) { list($response) = $this->unclaimedDraftCreateWithHttpInfo($unclaimed_draft_create_request); - return $response; } @@ -153,14 +163,16 @@ public function unclaimedDraftCreate(Model\UnclaimedDraftCreateRequest $unclaime * Create Unclaimed Draft * * @param Model\UnclaimedDraftCreateRequest $unclaimed_draft_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['unclaimedDraftCreate'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\UnclaimedDraftCreateResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::unclaimedDraftCreate. This method will eventually become unavailable */ - public function unclaimedDraftCreateWithHttpInfo(Model\UnclaimedDraftCreateRequest $unclaimed_draft_create_request) + public function unclaimedDraftCreateWithHttpInfo(Model\UnclaimedDraftCreateRequest $unclaimed_draft_create_request, string $contentType = self::contentTypes['unclaimedDraftCreate'][0]) { - $request = $this->unclaimedDraftCreateRequest($unclaimed_draft_create_request); + $request = $this->unclaimedDraftCreateRequest($unclaimed_draft_create_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -170,14 +182,14 @@ public function unclaimedDraftCreateWithHttpInfo(Model\UnclaimedDraftCreateReque } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -190,51 +202,73 @@ public function unclaimedDraftCreateWithHttpInfo(Model\UnclaimedDraftCreateReque sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\UnclaimedDraftCreateResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\UnclaimedDraftCreateResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\UnclaimedDraftCreateResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\UnclaimedDraftCreateResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\UnclaimedDraftCreateResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\UnclaimedDraftCreateResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -243,28 +277,19 @@ public function unclaimedDraftCreateWithHttpInfo(Model\UnclaimedDraftCreateReque $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\UnclaimedDraftCreateResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\UnclaimedDraftCreateResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -275,13 +300,15 @@ public function unclaimedDraftCreateWithHttpInfo(Model\UnclaimedDraftCreateReque * Create Unclaimed Draft * * @param Model\UnclaimedDraftCreateRequest $unclaimed_draft_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['unclaimedDraftCreate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::unclaimedDraftCreate. This method will eventually become unavailable */ - public function unclaimedDraftCreateAsync(Model\UnclaimedDraftCreateRequest $unclaimed_draft_create_request) + public function unclaimedDraftCreateAsync(Model\UnclaimedDraftCreateRequest $unclaimed_draft_create_request, string $contentType = self::contentTypes['unclaimedDraftCreate'][0]) { - return $this->unclaimedDraftCreateAsyncWithHttpInfo($unclaimed_draft_create_request) + return $this->unclaimedDraftCreateAsyncWithHttpInfo($unclaimed_draft_create_request, $contentType) ->then( function ($response) { return $response[0]; @@ -295,23 +322,28 @@ function ($response) { * Create Unclaimed Draft * * @param Model\UnclaimedDraftCreateRequest $unclaimed_draft_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['unclaimedDraftCreate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::unclaimedDraftCreate. This method will eventually become unavailable */ - public function unclaimedDraftCreateAsyncWithHttpInfo(Model\UnclaimedDraftCreateRequest $unclaimed_draft_create_request) + public function unclaimedDraftCreateAsyncWithHttpInfo(Model\UnclaimedDraftCreateRequest $unclaimed_draft_create_request, string $contentType = self::contentTypes['unclaimedDraftCreate'][0]) { $returnType = '\Dropbox\Sign\Model\UnclaimedDraftCreateResponse'; - $request = $this->unclaimedDraftCreateRequest($unclaimed_draft_create_request); + $request = $this->unclaimedDraftCreateRequest($unclaimed_draft_create_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -331,7 +363,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -341,11 +373,13 @@ function ($exception) { * Create request for operation 'unclaimedDraftCreate' * * @param Model\UnclaimedDraftCreateRequest $unclaimed_draft_create_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['unclaimedDraftCreate'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::unclaimedDraftCreate. This method will eventually become unavailable */ - public function unclaimedDraftCreateRequest(Model\UnclaimedDraftCreateRequest $unclaimed_draft_create_request) + public function unclaimedDraftCreateRequest(Model\UnclaimedDraftCreateRequest $unclaimed_draft_create_request, string $contentType = self::contentTypes['unclaimedDraftCreate'][0]) { // verify the required parameter 'unclaimed_draft_create_request' is set if ($unclaimed_draft_create_request === null || (is_array($unclaimed_draft_create_request) && count($unclaimed_draft_create_request) === 0)) { @@ -355,9 +389,11 @@ public function unclaimedDraftCreateRequest(Model\UnclaimedDraftCreateRequest $u } $resourcePath = '/unclaimed_draft/create'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $unclaimed_draft_create_request @@ -365,21 +401,17 @@ public function unclaimedDraftCreateRequest(Model\UnclaimedDraftCreateRequest $u $multipart = !empty($formParams); - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json', 'multipart/form-data'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($unclaimed_draft_create_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($unclaimed_draft_create_request)); } else { $httpBody = $unclaimed_draft_create_request; } @@ -398,22 +430,22 @@ public function unclaimedDraftCreateRequest(Model\UnclaimedDraftCreateRequest $u // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $unclaimed_draft_create_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -437,11 +469,11 @@ public function unclaimedDraftCreateRequest(Model\UnclaimedDraftCreateRequest $u $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -454,14 +486,13 @@ public function unclaimedDraftCreateRequest(Model\UnclaimedDraftCreateRequest $u * * @param Model\UnclaimedDraftCreateEmbeddedRequest $unclaimed_draft_create_embedded_request unclaimed_draft_create_embedded_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\UnclaimedDraftCreateResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function unclaimedDraftCreateEmbedded(Model\UnclaimedDraftCreateEmbeddedRequest $unclaimed_draft_create_embedded_request) { list($response) = $this->unclaimedDraftCreateEmbeddedWithHttpInfo($unclaimed_draft_create_embedded_request); - return $response; } @@ -471,14 +502,16 @@ public function unclaimedDraftCreateEmbedded(Model\UnclaimedDraftCreateEmbeddedR * Create Embedded Unclaimed Draft * * @param Model\UnclaimedDraftCreateEmbeddedRequest $unclaimed_draft_create_embedded_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['unclaimedDraftCreateEmbedded'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\UnclaimedDraftCreateResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::unclaimedDraftCreateEmbedded. This method will eventually become unavailable */ - public function unclaimedDraftCreateEmbeddedWithHttpInfo(Model\UnclaimedDraftCreateEmbeddedRequest $unclaimed_draft_create_embedded_request) + public function unclaimedDraftCreateEmbeddedWithHttpInfo(Model\UnclaimedDraftCreateEmbeddedRequest $unclaimed_draft_create_embedded_request, string $contentType = self::contentTypes['unclaimedDraftCreateEmbedded'][0]) { - $request = $this->unclaimedDraftCreateEmbeddedRequest($unclaimed_draft_create_embedded_request); + $request = $this->unclaimedDraftCreateEmbeddedRequest($unclaimed_draft_create_embedded_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -488,14 +521,14 @@ public function unclaimedDraftCreateEmbeddedWithHttpInfo(Model\UnclaimedDraftCre } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -508,51 +541,73 @@ public function unclaimedDraftCreateEmbeddedWithHttpInfo(Model\UnclaimedDraftCre sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\UnclaimedDraftCreateResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\UnclaimedDraftCreateResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\UnclaimedDraftCreateResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\UnclaimedDraftCreateResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\UnclaimedDraftCreateResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\UnclaimedDraftCreateResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -561,28 +616,19 @@ public function unclaimedDraftCreateEmbeddedWithHttpInfo(Model\UnclaimedDraftCre $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\UnclaimedDraftCreateResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\UnclaimedDraftCreateResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -593,13 +639,15 @@ public function unclaimedDraftCreateEmbeddedWithHttpInfo(Model\UnclaimedDraftCre * Create Embedded Unclaimed Draft * * @param Model\UnclaimedDraftCreateEmbeddedRequest $unclaimed_draft_create_embedded_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['unclaimedDraftCreateEmbedded'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::unclaimedDraftCreateEmbedded. This method will eventually become unavailable */ - public function unclaimedDraftCreateEmbeddedAsync(Model\UnclaimedDraftCreateEmbeddedRequest $unclaimed_draft_create_embedded_request) + public function unclaimedDraftCreateEmbeddedAsync(Model\UnclaimedDraftCreateEmbeddedRequest $unclaimed_draft_create_embedded_request, string $contentType = self::contentTypes['unclaimedDraftCreateEmbedded'][0]) { - return $this->unclaimedDraftCreateEmbeddedAsyncWithHttpInfo($unclaimed_draft_create_embedded_request) + return $this->unclaimedDraftCreateEmbeddedAsyncWithHttpInfo($unclaimed_draft_create_embedded_request, $contentType) ->then( function ($response) { return $response[0]; @@ -613,23 +661,28 @@ function ($response) { * Create Embedded Unclaimed Draft * * @param Model\UnclaimedDraftCreateEmbeddedRequest $unclaimed_draft_create_embedded_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['unclaimedDraftCreateEmbedded'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::unclaimedDraftCreateEmbedded. This method will eventually become unavailable */ - public function unclaimedDraftCreateEmbeddedAsyncWithHttpInfo(Model\UnclaimedDraftCreateEmbeddedRequest $unclaimed_draft_create_embedded_request) + public function unclaimedDraftCreateEmbeddedAsyncWithHttpInfo(Model\UnclaimedDraftCreateEmbeddedRequest $unclaimed_draft_create_embedded_request, string $contentType = self::contentTypes['unclaimedDraftCreateEmbedded'][0]) { $returnType = '\Dropbox\Sign\Model\UnclaimedDraftCreateResponse'; - $request = $this->unclaimedDraftCreateEmbeddedRequest($unclaimed_draft_create_embedded_request); + $request = $this->unclaimedDraftCreateEmbeddedRequest($unclaimed_draft_create_embedded_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -649,7 +702,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -659,11 +712,13 @@ function ($exception) { * Create request for operation 'unclaimedDraftCreateEmbedded' * * @param Model\UnclaimedDraftCreateEmbeddedRequest $unclaimed_draft_create_embedded_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['unclaimedDraftCreateEmbedded'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::unclaimedDraftCreateEmbedded. This method will eventually become unavailable */ - public function unclaimedDraftCreateEmbeddedRequest(Model\UnclaimedDraftCreateEmbeddedRequest $unclaimed_draft_create_embedded_request) + public function unclaimedDraftCreateEmbeddedRequest(Model\UnclaimedDraftCreateEmbeddedRequest $unclaimed_draft_create_embedded_request, string $contentType = self::contentTypes['unclaimedDraftCreateEmbedded'][0]) { // verify the required parameter 'unclaimed_draft_create_embedded_request' is set if ($unclaimed_draft_create_embedded_request === null || (is_array($unclaimed_draft_create_embedded_request) && count($unclaimed_draft_create_embedded_request) === 0)) { @@ -673,9 +728,11 @@ public function unclaimedDraftCreateEmbeddedRequest(Model\UnclaimedDraftCreateEm } $resourcePath = '/unclaimed_draft/create_embedded'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $unclaimed_draft_create_embedded_request @@ -683,21 +740,17 @@ public function unclaimedDraftCreateEmbeddedRequest(Model\UnclaimedDraftCreateEm $multipart = !empty($formParams); - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json', 'multipart/form-data'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($unclaimed_draft_create_embedded_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($unclaimed_draft_create_embedded_request)); } else { $httpBody = $unclaimed_draft_create_embedded_request; } @@ -716,22 +769,22 @@ public function unclaimedDraftCreateEmbeddedRequest(Model\UnclaimedDraftCreateEm // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $unclaimed_draft_create_embedded_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -755,11 +808,11 @@ public function unclaimedDraftCreateEmbeddedRequest(Model\UnclaimedDraftCreateEm $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -772,14 +825,13 @@ public function unclaimedDraftCreateEmbeddedRequest(Model\UnclaimedDraftCreateEm * * @param Model\UnclaimedDraftCreateEmbeddedWithTemplateRequest $unclaimed_draft_create_embedded_with_template_request unclaimed_draft_create_embedded_with_template_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\UnclaimedDraftCreateResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function unclaimedDraftCreateEmbeddedWithTemplate(Model\UnclaimedDraftCreateEmbeddedWithTemplateRequest $unclaimed_draft_create_embedded_with_template_request) { list($response) = $this->unclaimedDraftCreateEmbeddedWithTemplateWithHttpInfo($unclaimed_draft_create_embedded_with_template_request); - return $response; } @@ -789,14 +841,16 @@ public function unclaimedDraftCreateEmbeddedWithTemplate(Model\UnclaimedDraftCre * Create Embedded Unclaimed Draft with Template * * @param Model\UnclaimedDraftCreateEmbeddedWithTemplateRequest $unclaimed_draft_create_embedded_with_template_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['unclaimedDraftCreateEmbeddedWithTemplate'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\UnclaimedDraftCreateResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::unclaimedDraftCreateEmbeddedWithTemplate. This method will eventually become unavailable */ - public function unclaimedDraftCreateEmbeddedWithTemplateWithHttpInfo(Model\UnclaimedDraftCreateEmbeddedWithTemplateRequest $unclaimed_draft_create_embedded_with_template_request) + public function unclaimedDraftCreateEmbeddedWithTemplateWithHttpInfo(Model\UnclaimedDraftCreateEmbeddedWithTemplateRequest $unclaimed_draft_create_embedded_with_template_request, string $contentType = self::contentTypes['unclaimedDraftCreateEmbeddedWithTemplate'][0]) { - $request = $this->unclaimedDraftCreateEmbeddedWithTemplateRequest($unclaimed_draft_create_embedded_with_template_request); + $request = $this->unclaimedDraftCreateEmbeddedWithTemplateRequest($unclaimed_draft_create_embedded_with_template_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -806,14 +860,14 @@ public function unclaimedDraftCreateEmbeddedWithTemplateWithHttpInfo(Model\Uncla } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -826,51 +880,73 @@ public function unclaimedDraftCreateEmbeddedWithTemplateWithHttpInfo(Model\Uncla sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\UnclaimedDraftCreateResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\UnclaimedDraftCreateResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\UnclaimedDraftCreateResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\UnclaimedDraftCreateResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\UnclaimedDraftCreateResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\UnclaimedDraftCreateResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -879,28 +955,19 @@ public function unclaimedDraftCreateEmbeddedWithTemplateWithHttpInfo(Model\Uncla $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\UnclaimedDraftCreateResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\UnclaimedDraftCreateResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -911,13 +978,15 @@ public function unclaimedDraftCreateEmbeddedWithTemplateWithHttpInfo(Model\Uncla * Create Embedded Unclaimed Draft with Template * * @param Model\UnclaimedDraftCreateEmbeddedWithTemplateRequest $unclaimed_draft_create_embedded_with_template_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['unclaimedDraftCreateEmbeddedWithTemplate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::unclaimedDraftCreateEmbeddedWithTemplate. This method will eventually become unavailable */ - public function unclaimedDraftCreateEmbeddedWithTemplateAsync(Model\UnclaimedDraftCreateEmbeddedWithTemplateRequest $unclaimed_draft_create_embedded_with_template_request) + public function unclaimedDraftCreateEmbeddedWithTemplateAsync(Model\UnclaimedDraftCreateEmbeddedWithTemplateRequest $unclaimed_draft_create_embedded_with_template_request, string $contentType = self::contentTypes['unclaimedDraftCreateEmbeddedWithTemplate'][0]) { - return $this->unclaimedDraftCreateEmbeddedWithTemplateAsyncWithHttpInfo($unclaimed_draft_create_embedded_with_template_request) + return $this->unclaimedDraftCreateEmbeddedWithTemplateAsyncWithHttpInfo($unclaimed_draft_create_embedded_with_template_request, $contentType) ->then( function ($response) { return $response[0]; @@ -931,23 +1000,28 @@ function ($response) { * Create Embedded Unclaimed Draft with Template * * @param Model\UnclaimedDraftCreateEmbeddedWithTemplateRequest $unclaimed_draft_create_embedded_with_template_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['unclaimedDraftCreateEmbeddedWithTemplate'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::unclaimedDraftCreateEmbeddedWithTemplate. This method will eventually become unavailable */ - public function unclaimedDraftCreateEmbeddedWithTemplateAsyncWithHttpInfo(Model\UnclaimedDraftCreateEmbeddedWithTemplateRequest $unclaimed_draft_create_embedded_with_template_request) + public function unclaimedDraftCreateEmbeddedWithTemplateAsyncWithHttpInfo(Model\UnclaimedDraftCreateEmbeddedWithTemplateRequest $unclaimed_draft_create_embedded_with_template_request, string $contentType = self::contentTypes['unclaimedDraftCreateEmbeddedWithTemplate'][0]) { $returnType = '\Dropbox\Sign\Model\UnclaimedDraftCreateResponse'; - $request = $this->unclaimedDraftCreateEmbeddedWithTemplateRequest($unclaimed_draft_create_embedded_with_template_request); + $request = $this->unclaimedDraftCreateEmbeddedWithTemplateRequest($unclaimed_draft_create_embedded_with_template_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -967,7 +1041,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -977,11 +1051,13 @@ function ($exception) { * Create request for operation 'unclaimedDraftCreateEmbeddedWithTemplate' * * @param Model\UnclaimedDraftCreateEmbeddedWithTemplateRequest $unclaimed_draft_create_embedded_with_template_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['unclaimedDraftCreateEmbeddedWithTemplate'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::unclaimedDraftCreateEmbeddedWithTemplate. This method will eventually become unavailable */ - public function unclaimedDraftCreateEmbeddedWithTemplateRequest(Model\UnclaimedDraftCreateEmbeddedWithTemplateRequest $unclaimed_draft_create_embedded_with_template_request) + public function unclaimedDraftCreateEmbeddedWithTemplateRequest(Model\UnclaimedDraftCreateEmbeddedWithTemplateRequest $unclaimed_draft_create_embedded_with_template_request, string $contentType = self::contentTypes['unclaimedDraftCreateEmbeddedWithTemplate'][0]) { // verify the required parameter 'unclaimed_draft_create_embedded_with_template_request' is set if ($unclaimed_draft_create_embedded_with_template_request === null || (is_array($unclaimed_draft_create_embedded_with_template_request) && count($unclaimed_draft_create_embedded_with_template_request) === 0)) { @@ -991,9 +1067,11 @@ public function unclaimedDraftCreateEmbeddedWithTemplateRequest(Model\UnclaimedD } $resourcePath = '/unclaimed_draft/create_embedded_with_template'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $unclaimed_draft_create_embedded_with_template_request @@ -1001,21 +1079,17 @@ public function unclaimedDraftCreateEmbeddedWithTemplateRequest(Model\UnclaimedD $multipart = !empty($formParams); - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json', 'multipart/form-data'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($unclaimed_draft_create_embedded_with_template_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($unclaimed_draft_create_embedded_with_template_request)); } else { $httpBody = $unclaimed_draft_create_embedded_with_template_request; } @@ -1034,22 +1108,22 @@ public function unclaimedDraftCreateEmbeddedWithTemplateRequest(Model\UnclaimedD // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $unclaimed_draft_create_embedded_with_template_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -1073,11 +1147,11 @@ public function unclaimedDraftCreateEmbeddedWithTemplateRequest(Model\UnclaimedD $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1088,17 +1162,16 @@ public function unclaimedDraftCreateEmbeddedWithTemplateRequest(Model\UnclaimedD * * Edit and Resend Unclaimed Draft * - * @param string $signature_request_id The ID of the signature request to edit and resend. (required) + * @param string $signature_request_id The ID of the signature request to edit and resend. (required) * @param Model\UnclaimedDraftEditAndResendRequest $unclaimed_draft_edit_and_resend_request unclaimed_draft_edit_and_resend_request (required) * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return Model\UnclaimedDraftCreateResponse + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException */ public function unclaimedDraftEditAndResend(string $signature_request_id, Model\UnclaimedDraftEditAndResendRequest $unclaimed_draft_edit_and_resend_request) { list($response) = $this->unclaimedDraftEditAndResendWithHttpInfo($signature_request_id, $unclaimed_draft_edit_and_resend_request); - return $response; } @@ -1107,16 +1180,18 @@ public function unclaimedDraftEditAndResend(string $signature_request_id, Model\ * * Edit and Resend Unclaimed Draft * - * @param string $signature_request_id The ID of the signature request to edit and resend. (required) + * @param string $signature_request_id The ID of the signature request to edit and resend. (required) * @param Model\UnclaimedDraftEditAndResendRequest $unclaimed_draft_edit_and_resend_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['unclaimedDraftEditAndResend'] to see the possible values for this operation * - * @throws ApiException on non-2xx response - * @throws InvalidArgumentException * @return array of Model\UnclaimedDraftCreateResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @deprecated Prefer to use ::unclaimedDraftEditAndResend. This method will eventually become unavailable */ - public function unclaimedDraftEditAndResendWithHttpInfo(string $signature_request_id, Model\UnclaimedDraftEditAndResendRequest $unclaimed_draft_edit_and_resend_request) + public function unclaimedDraftEditAndResendWithHttpInfo(string $signature_request_id, Model\UnclaimedDraftEditAndResendRequest $unclaimed_draft_edit_and_resend_request, string $contentType = self::contentTypes['unclaimedDraftEditAndResend'][0]) { - $request = $this->unclaimedDraftEditAndResendRequest($signature_request_id, $unclaimed_draft_edit_and_resend_request); + $request = $this->unclaimedDraftEditAndResendRequest($signature_request_id, $unclaimed_draft_edit_and_resend_request, $contentType); try { $options = $this->createHttpClientOption(); @@ -1126,14 +1201,14 @@ public function unclaimedDraftEditAndResendWithHttpInfo(string $signature_reques } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $e->getResponse() ? (string)$e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), + (int)$e->getCode(), null, null ); @@ -1146,51 +1221,73 @@ public function unclaimedDraftEditAndResendWithHttpInfo(string $signature_reques sprintf( '[%d] Error connecting to the API (%s)', $statusCode, - (string) $request->getUri() + (string)$request->getUri() ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } - $statusCode = $response->getStatusCode(); - - if ($statusCode === 200) { - if ('\Dropbox\Sign\Model\UnclaimedDraftCreateResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\UnclaimedDraftCreateResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + $result = $this->handleRangeCodeResponse( + $response, + '4XX', + '\Dropbox\Sign\Model\ErrorResponse' + ); + if ($result) { + return $result; } - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('\Dropbox\Sign\Model\ErrorResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + switch ($statusCode) { + case 200: + if ('\Dropbox\Sign\Model\UnclaimedDraftCreateResponse' === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + if ('\Dropbox\Sign\Model\UnclaimedDraftCreateResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\ErrorResponse', []), - $response->getStatusCode(), - $response->getHeaders(), - ]; + return [ + ObjectSerializer::deserialize($content, '\Dropbox\Sign\Model\UnclaimedDraftCreateResponse', []), + $response->getStatusCode(), + $response->getHeaders(), + ]; } $returnType = '\Dropbox\Sign\Model\UnclaimedDraftCreateResponse'; if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -1199,28 +1296,19 @@ public function unclaimedDraftEditAndResendWithHttpInfo(string $signature_reques $response->getHeaders(), ]; } catch (ApiException $e) { - $statusCode = $e->getCode(); - - if ($statusCode === 200) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\UnclaimedDraftCreateResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + if ($this->handleRangeCodeException($e, '4XX', '\Dropbox\Sign\Model\ErrorResponse')) { + throw $e; } - - $rangeCodeLeft = (int) (substr('4XX', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('4XX', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\Dropbox\Sign\Model\ErrorResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Dropbox\Sign\Model\UnclaimedDraftCreateResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } - throw $e; } } @@ -1230,15 +1318,17 @@ public function unclaimedDraftEditAndResendWithHttpInfo(string $signature_reques * * Edit and Resend Unclaimed Draft * - * @param string $signature_request_id The ID of the signature request to edit and resend. (required) + * @param string $signature_request_id The ID of the signature request to edit and resend. (required) * @param Model\UnclaimedDraftEditAndResendRequest $unclaimed_draft_edit_and_resend_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['unclaimedDraftEditAndResend'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::unclaimedDraftEditAndResend. This method will eventually become unavailable */ - public function unclaimedDraftEditAndResendAsync(string $signature_request_id, Model\UnclaimedDraftEditAndResendRequest $unclaimed_draft_edit_and_resend_request) + public function unclaimedDraftEditAndResendAsync(string $signature_request_id, Model\UnclaimedDraftEditAndResendRequest $unclaimed_draft_edit_and_resend_request, string $contentType = self::contentTypes['unclaimedDraftEditAndResend'][0]) { - return $this->unclaimedDraftEditAndResendAsyncWithHttpInfo($signature_request_id, $unclaimed_draft_edit_and_resend_request) + return $this->unclaimedDraftEditAndResendAsyncWithHttpInfo($signature_request_id, $unclaimed_draft_edit_and_resend_request, $contentType) ->then( function ($response) { return $response[0]; @@ -1251,25 +1341,30 @@ function ($response) { * * Edit and Resend Unclaimed Draft * - * @param string $signature_request_id The ID of the signature request to edit and resend. (required) + * @param string $signature_request_id The ID of the signature request to edit and resend. (required) * @param Model\UnclaimedDraftEditAndResendRequest $unclaimed_draft_edit_and_resend_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['unclaimedDraftEditAndResend'] to see the possible values for this operation * + * @return \GuzzleHttp\Promise\PromiseInterface * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @deprecated Prefer to use ::unclaimedDraftEditAndResend. This method will eventually become unavailable */ - public function unclaimedDraftEditAndResendAsyncWithHttpInfo(string $signature_request_id, Model\UnclaimedDraftEditAndResendRequest $unclaimed_draft_edit_and_resend_request) + public function unclaimedDraftEditAndResendAsyncWithHttpInfo(string $signature_request_id, Model\UnclaimedDraftEditAndResendRequest $unclaimed_draft_edit_and_resend_request, string $contentType = self::contentTypes['unclaimedDraftEditAndResend'][0]) { $returnType = '\Dropbox\Sign\Model\UnclaimedDraftCreateResponse'; - $request = $this->unclaimedDraftEditAndResendRequest($signature_request_id, $unclaimed_draft_edit_and_resend_request); + $request = $this->unclaimedDraftEditAndResendRequest($signature_request_id, $unclaimed_draft_edit_and_resend_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer + $content = $response->getBody(); // stream goes to serializer } else { - $content = (string) $response->getBody(); + $content = (string)$response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -1289,7 +1384,7 @@ function ($exception) { ), $statusCode, $response->getHeaders(), - (string) $response->getBody() + (string)$response->getBody() ); } ); @@ -1298,13 +1393,15 @@ function ($exception) { /** * Create request for operation 'unclaimedDraftEditAndResend' * - * @param string $signature_request_id The ID of the signature request to edit and resend. (required) + * @param string $signature_request_id The ID of the signature request to edit and resend. (required) * @param Model\UnclaimedDraftEditAndResendRequest $unclaimed_draft_edit_and_resend_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['unclaimedDraftEditAndResend'] to see the possible values for this operation * + * @return Request * @throws InvalidArgumentException - * @return Psr7\Request + * @deprecated Prefer to use ::unclaimedDraftEditAndResend. This method will eventually become unavailable */ - public function unclaimedDraftEditAndResendRequest(string $signature_request_id, Model\UnclaimedDraftEditAndResendRequest $unclaimed_draft_edit_and_resend_request) + public function unclaimedDraftEditAndResendRequest(string $signature_request_id, Model\UnclaimedDraftEditAndResendRequest $unclaimed_draft_edit_and_resend_request, string $contentType = self::contentTypes['unclaimedDraftEditAndResend'][0]) { // verify the required parameter 'signature_request_id' is set if ($signature_request_id === null || (is_array($signature_request_id) && count($signature_request_id) === 0)) { @@ -1312,6 +1409,7 @@ public function unclaimedDraftEditAndResendRequest(string $signature_request_id, 'Missing the required parameter $signature_request_id when calling unclaimedDraftEditAndResend' ); } + // verify the required parameter 'unclaimed_draft_edit_and_resend_request' is set if ($unclaimed_draft_edit_and_resend_request === null || (is_array($unclaimed_draft_edit_and_resend_request) && count($unclaimed_draft_edit_and_resend_request) === 0)) { throw new InvalidArgumentException( @@ -1320,9 +1418,11 @@ public function unclaimedDraftEditAndResendRequest(string $signature_request_id, } $resourcePath = '/unclaimed_draft/edit_and_resend/{signature_request_id}'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; $formParams = ObjectSerializer::getFormParams( $unclaimed_draft_edit_and_resend_request @@ -1333,27 +1433,23 @@ public function unclaimedDraftEditAndResendRequest(string $signature_request_id, // path params if ($signature_request_id !== null) { $resourcePath = str_replace( - '{' . 'signature_request_id' . '}', + '{signature_request_id}', ObjectSerializer::toPathValue($signature_request_id), $resourcePath ); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + $multipart ? ['multipart/form-data'] : ['application/json'], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($unclaimed_draft_edit_and_resend_request)); + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($unclaimed_draft_edit_and_resend_request)); } else { $httpBody = $unclaimed_draft_edit_and_resend_request; } @@ -1372,22 +1468,22 @@ public function unclaimedDraftEditAndResendRequest(string $signature_request_id, // for HTTP post (form) if (!empty($body)) { $multipartContents[] = [ - 'name' => 'body', + 'name' => 'body', 'contents' => $body, - 'headers' => ['Content-Type' => 'application/json'], + 'headers' => ['Content-Type' => 'application/json'], ]; } if ($payloadHook = $this->config->getPayloadHook()) { $payloadHook('multipart', $multipartContents, $unclaimed_draft_edit_and_resend_request); } - - $httpBody = new Psr7\MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); + $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } @@ -1411,11 +1507,11 @@ public function unclaimedDraftEditAndResendRequest(string $signature_request_id, $headers ); - $query = Psr7\Query::build($queryParams); - - return new Psr7\Request( + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1424,8 +1520,8 @@ public function unclaimedDraftEditAndResendRequest(string $signature_request_id, /** * Create http client option * - * @throws RuntimeException on file opening failure * @return array of http client options + * @throws RuntimeException on file opening failure */ protected function createHttpClientOption() { @@ -1439,4 +1535,66 @@ protected function createHttpClientOption() return $options; } + + /** + * @return object|array|null + */ + private function handleRangeCodeResponse( + ResponseInterface $response, + string $rangeCode, + string $returnDataType + ) { + $statusCode = $response->getStatusCode(); + $rangeCodeLeft = (int)(substr($rangeCode, 0, 1) . '00'); + $rangeCodeRight = (int)(substr($rangeCode, 0, 1) . '99'); + + if ( + $statusCode < $rangeCodeLeft + || $statusCode > $rangeCodeRight + ) { + return null; + } + + if ($returnDataType === '\SplFileObject') { + $content = $response->getBody(); // stream goes to serializer + } else { + $content = (string)$response->getBody(); + } + + return [ + ObjectSerializer::deserialize($content, $returnDataType, []), + $statusCode, + $response->getHeaders(), + ]; + } + + /** + * @return object|array|null + */ + private function handleRangeCodeException( + ApiException $e, + string $rangeCode, + string $exceptionDataType + ): bool { + $statusCode = $e->getCode(); + $rangeCodeLeft = (int)(substr($rangeCode, 0, 1) . '00'); + $rangeCodeRight = (int)(substr($rangeCode, 0, 1) . '99'); + + if ( + $statusCode < $rangeCodeLeft + || $statusCode > $rangeCodeRight + ) { + return false; + } + + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + $exceptionDataType, + $e->getResponseHeaders() + ); + + $e->setResponseObject($data); + + return true; + } } diff --git a/sdks/php/src/ApiException.php b/sdks/php/src/ApiException.php index d86bb4224..3d4a49ca7 100644 --- a/sdks/php/src/ApiException.php +++ b/sdks/php/src/ApiException.php @@ -4,7 +4,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -16,7 +15,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -34,7 +33,6 @@ * ApiException Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ class ApiException extends Exception @@ -49,7 +47,7 @@ class ApiException extends Exception /** * The HTTP header of the server response. * - * @var string[]|null + * @var string[][]|null */ protected $responseHeaders; @@ -63,10 +61,10 @@ class ApiException extends Exception /** * Constructor * - * @param string $message Error message - * @param int $code HTTP status code - * @param string[]|null $responseHeaders HTTP response header - * @param stdClass|string|null $responseBody HTTP decoded body of the server response either as \stdClass or string + * @param string $message Error message + * @param int $code HTTP status code + * @param string[][]|null $responseHeaders HTTP response header + * @param stdClass|string|null $responseBody HTTP decoded body of the server response either as \stdClass or string */ public function __construct(string $message = '', int $code = 0, ?array $responseHeaders = [], $responseBody = null) { @@ -78,7 +76,7 @@ public function __construct(string $message = '', int $code = 0, ?array $respons /** * Gets the HTTP response header * - * @return string[]|null HTTP response header + * @return string[][]|null HTTP response header */ public function getResponseHeaders() { @@ -98,9 +96,7 @@ public function getResponseBody() /** * Sets the deserialized response object (during deserialization) * - * @param mixed $obj Deserialized response object - * - * @return void + * @param string|int|object|array|mixed $obj Deserialized response object */ public function setResponseObject($obj) { diff --git a/sdks/php/src/Configuration.php b/sdks/php/src/Configuration.php index 584f4a2a2..8d4d1a042 100644 --- a/sdks/php/src/Configuration.php +++ b/sdks/php/src/Configuration.php @@ -4,7 +4,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -16,7 +15,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -34,15 +33,29 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ class Configuration { + public const BOOLEAN_FORMAT_INT = 'int'; + public const BOOLEAN_FORMAT_STRING = 'string'; + + /** @var Configuration */ + private static $defaultConfiguration; + /** - * @var Configuration + * Associate array to store API key(s) + * + * @var string[] */ - private static $defaultConfiguration; + protected $apiKeys = []; + + /** + * Associate array to store API prefix (e.g. Bearer) + * + * @var string[] + */ + protected $apiKeyPrefixes = []; /** * Access token for OAuth/Bearer authentication @@ -51,6 +64,13 @@ class Configuration */ protected $accessToken = ''; + /** + * Boolean format for query string + * + * @var string + */ + protected $booleanFormatForQueryString = self::BOOLEAN_FORMAT_INT; + /** * Username for HTTP basic authentication * @@ -58,6 +78,13 @@ class Configuration */ protected $username = ''; + /** + * Password for HTTP basic authentication + * + * @var string + */ + protected $password = ''; + /** * The host * @@ -70,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'OpenAPI-Generator/1.5-dev/PHP'; + protected $userAgent = 'OpenAPI-Generator/1.6-dev/PHP'; /** * Debug switch (default set to false) @@ -101,7 +128,7 @@ class Configuration protected $options = []; /** @var ?callable */ - protected $payloadHook = null; + protected $payloadHook; /** * Constructor @@ -111,17 +138,68 @@ public function __construct() $this->tempFolderPath = sys_get_temp_dir(); } + /** + * Sets API key + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * @param string $key API key or token + * + * @return $this + */ + protected function setApiKey(string $apiKeyIdentifier, string $key) + { + $this->apiKeys[$apiKeyIdentifier] = $key; + return $this; + } + + /** + * Gets API key + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * + * @return string|null API key or token + */ + protected function getApiKey(string $apiKeyIdentifier) + { + return isset($this->apiKeys[$apiKeyIdentifier]) ? $this->apiKeys[$apiKeyIdentifier] : null; + } + + /** + * Sets the prefix for API key (e.g. Bearer) + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * @param string $prefix API key prefix, e.g. Bearer + * + * @return $this + */ + protected function setApiKeyPrefix(string $apiKeyIdentifier, string $prefix) + { + $this->apiKeyPrefixes[$apiKeyIdentifier] = $prefix; + return $this; + } + + /** + * Gets API key prefix + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * + * @return string|null + */ + protected function getApiKeyPrefix(string $apiKeyIdentifier) + { + return isset($this->apiKeyPrefixes[$apiKeyIdentifier]) ? $this->apiKeyPrefixes[$apiKeyIdentifier] : null; + } + /** * Sets the access token for OAuth * * @param string $accessToken Token for OAuth * - * @return self + * @return $this */ public function setAccessToken(string $accessToken) { $this->accessToken = $accessToken; - return $this; } @@ -136,14 +214,39 @@ public function getAccessToken() } /** - * Sets the API key + * Sets boolean format for query string. + * + * @param string $booleanFormat Boolean format for query string + * + * @return $this + */ + protected function setBooleanFormatForQueryString(string $booleanFormat) + { + $this->booleanFormatForQueryString = $booleanFormat; + + return $this; + } + + /** + * Gets boolean format for query string. * - * @param string $key API key or token + * @return string Boolean format for query string */ - public function setUsername(string $key): self + public function getBooleanFormatForQueryString(): string { - $this->username = $key; + return $this->booleanFormatForQueryString; + } + /** + * Sets the username for HTTP basic authentication + * + * @param string $username Username for HTTP basic authentication + * + * @return $this + */ + public function setUsername(string $username) + { + $this->username = $username; return $this; } @@ -157,17 +260,39 @@ public function getUsername() return $this->username; } + /** + * Sets the password for HTTP basic authentication + * + * @param string $password Password for HTTP basic authentication + * + * @return $this + */ + protected function setPassword(string $password) + { + $this->password = $password; + return $this; + } + + /** + * Gets the password for HTTP basic authentication + * + * @return string Password for HTTP basic authentication + */ + protected function getPassword() + { + return $this->password; + } + /** * Sets the host * * @param string $host Host * - * @return self + * @return $this */ public function setHost(string $host) { $this->host = $host; - return $this; } @@ -186,8 +311,8 @@ public function getHost() * * @param string $userAgent the user agent of the api client * + * @return $this * @throws InvalidArgumentException - * @return self */ public function setUserAgent(string $userAgent) { @@ -196,7 +321,6 @@ public function setUserAgent(string $userAgent) } $this->userAgent = $userAgent; - return $this; } @@ -215,12 +339,11 @@ public function getUserAgent() * * @param bool $debug Debug flag * - * @return self + * @return $this */ public function setDebug(bool $debug) { $this->debug = $debug; - return $this; } @@ -239,12 +362,11 @@ public function getDebug() * * @param string $debugFile Debug file * - * @return self + * @return $this */ public function setDebugFile(string $debugFile) { $this->debugFile = $debugFile; - return $this; } @@ -263,12 +385,11 @@ public function getDebugFile() * * @param string $tempFolderPath Temp folder path * - * @return self + * @return $this */ public function setTempFolderPath(string $tempFolderPath) { $this->tempFolderPath = $tempFolderPath; - return $this; } @@ -300,8 +421,6 @@ public static function getDefaultConfiguration() * Sets the default configuration instance * * @param Configuration $config An instance of the Configuration Object - * - * @return void */ public static function setDefaultConfiguration(Configuration $config) { @@ -319,12 +438,37 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 3.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 1.5-dev' . PHP_EOL; + $report .= ' SDK Package Version: 1.6-dev' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; } + /** + * Get API key (with prefix if set) + * + * @param string $apiKeyIdentifier name of apikey + * + * @return string|null API key with the prefix + */ + protected function getApiKeyWithPrefix(string $apiKeyIdentifier) + { + $prefix = $this->getApiKeyPrefix($apiKeyIdentifier); + $apiKey = $this->getApiKey($apiKeyIdentifier); + + if ($apiKey === null) { + return null; + } + + if ($prefix === null) { + $keyWithPrefix = $apiKey; + } else { + $keyWithPrefix = $prefix . ' ' . $apiKey; + } + + return $keyWithPrefix; + } + /** * Returns an array of host settings * @@ -341,35 +485,34 @@ public function getHostSettings() } /** - * Returns URL based on the index and variables + * Returns URL based on host settings, index and variables * - * @param int $index index of the host settings - * @param array|null $variables hash of variable and the corresponding value (optional) - * @return string URL based on host settings + * @param array $hostSettings array of host settings, generated from getHostSettings() or equivalent from the API clients + * @param int $hostIndex index of the host settings + * @param array|null $variables hash of variable and the corresponding value (optional) + * @return string URL based on host settings */ - public function getHostFromSettings(int $index, ?array $variables = null) + public static function getHostString(array $hostSettings, int $hostIndex, array $variables = null) { if (null === $variables) { $variables = []; } - $hosts = $this->getHostSettings(); - // check array index out of bound - if ($index < 0 || $index >= sizeof($hosts)) { - throw new InvalidArgumentException("Invalid index $index when selecting the host. Must be less than " . sizeof($hosts)); + if ($hostIndex < 0 || $hostIndex >= count($hostSettings)) { + throw new InvalidArgumentException("Invalid index {$hostIndex} when selecting the host. Must be less than " . count($hostSettings)); } - $host = $hosts[$index]; + $host = $hostSettings[$hostIndex]; $url = $host['url']; // go through variable and assign a value foreach ($host['variables'] ?? [] as $name => $variable) { if (array_key_exists($name, $variables)) { // check to see if it's in the variables provided by the user - if (in_array($variables[$name], $variable['enum_values'], true)) { // check to see if the value is in the enum + if (!isset($variable['enum_values']) || in_array($variables[$name], $variable['enum_values'], true)) { // check to see if the value is in the enum $url = str_replace('{' . $name . '}', $variables[$name], $url); } else { - throw new InvalidArgumentException("The variable `$name` in the host URL has invalid value " . $variables[$name] . '. Must be ' . join(',', $variable['enum_values']) . '.'); + throw new InvalidArgumentException("The variable `{$name}` in the host URL has invalid value " . $variables[$name] . '. Must be ' . join(',', $variable['enum_values']) . '.'); } } else { // use default value @@ -381,8 +524,17 @@ public function getHostFromSettings(int $index, ?array $variables = null) } /** - * Set extra request options + * Returns URL based on the index and variables + * + * @param int $index index of the host settings + * @param array|null $variables hash of variable and the corresponding value (optional) + * @return string URL based on host settings */ + public function getHostFromSettings(int $index, ?array $variables = null) + { + return self::getHostString($this->getHostSettings(), $index, $variables); + } + public function setOptions(array $options): self { $this->options = $options; diff --git a/sdks/php/src/EventCallbackHelper.php b/sdks/php/src/EventCallbackHelper.php index 094e770c4..16e76ec8b 100644 --- a/sdks/php/src/EventCallbackHelper.php +++ b/sdks/php/src/EventCallbackHelper.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -32,7 +31,6 @@ * EventCallbackHelper Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ abstract class EventCallbackHelper diff --git a/sdks/php/src/HeaderSelector.php b/sdks/php/src/HeaderSelector.php index 8529bc2a2..fe1faf2c1 100644 --- a/sdks/php/src/HeaderSelector.php +++ b/sdks/php/src/HeaderSelector.php @@ -4,7 +4,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -16,7 +15,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -28,20 +27,18 @@ namespace Dropbox\Sign; /** - * ApiException Class Doc Comment + * HeaderSelector Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ class HeaderSelector { /** - * @param string[] $accept - * @param string[] $contentTypes - * @return array + * @param string[] $accept + * @return string[] */ - public function selectHeaders(array $accept, array $contentTypes) + public function selectHeaders(array $accept, string $contentType, bool $isMultipart): array { $headers = []; @@ -50,57 +47,183 @@ public function selectHeaders(array $accept, array $contentTypes) $headers['Accept'] = $accept; } - $headers['Content-Type'] = $this->selectContentTypeHeader($contentTypes); + if (!$isMultipart) { + if ($contentType === '') { + $contentType = 'application/json'; + } + + $headers['Content-Type'] = $contentType; + } return $headers; } /** - * @param string[] $accept - * @return array + * Return the header 'Accept' based on an array of Accept provided. + * + * @param string[] $accept Array of header + * + * @return string|null Accept (e.g. application/json) */ - public function selectHeadersForMultipart(array $accept) + private function selectAcceptHeader(array $accept): ?string { - $headers = $this->selectHeaders($accept, []); + // filter out empty entries + $accept = array_filter($accept); - unset($headers['Content-Type']); + if (count($accept) === 0) { + return null; + } - return $headers; + // If there's only one Accept header, just use it + if (count($accept) === 1) { + return reset($accept); + } + + // If none of the available Accept headers is of type "json", then just use all them + $headersWithJson = preg_grep('~(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$~', $accept); + if (count($headersWithJson) === 0) { + return implode(',', $accept); + } + + // If we got here, then we need add quality values (weight), as described in IETF RFC 9110, Items 12.4.2/12.5.1, + // to give the highest priority to json-like headers - recalculating the existing ones, if needed + return $this->getAcceptHeaderWithAdjustedWeight($accept, $headersWithJson); } /** - * Return the header 'Accept' based on an array of Accept provided + * Create an Accept header string from the given "Accept" headers array, recalculating all weights * - * @param string[] $accept Array of header + * @param string[] $accept Array of Accept Headers + * @param string[] $headersWithJson Array of Accept Headers of type "json" * - * @return string|null Accept (e.g. application/json) + * @return string "Accept" Header (e.g. "application/json, text/html; q=0.9") */ - private function selectAcceptHeader(array $accept) + private function getAcceptHeaderWithAdjustedWeight(array $accept, array $headersWithJson): string { - if (count($accept) === 0 || (count($accept) === 1 && $accept[0] === '')) { - return null; - } elseif ($jsonAccept = preg_grep('~(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$~', $accept)) { - return implode(',', $jsonAccept); - } else { - return implode(',', $accept); + $processedHeaders = [ + 'withApplicationJson' => [], + 'withJson' => [], + 'withoutJson' => [], + ]; + + foreach ($accept as $header) { + $headerData = $this->getHeaderAndWeight($header); + + if (stripos($headerData['header'], 'application/json') === 0) { + $processedHeaders['withApplicationJson'][] = $headerData; + } elseif (in_array($header, $headersWithJson, true)) { + $processedHeaders['withJson'][] = $headerData; + } else { + $processedHeaders['withoutJson'][] = $headerData; + } } + + $acceptHeaders = []; + $currentWeight = 1000; + + $hasMoreThan28Headers = count($accept) > 28; + + foreach ($processedHeaders as $headers) { + if (count($headers) > 0) { + $acceptHeaders[] = $this->adjustWeight($headers, $currentWeight, $hasMoreThan28Headers); + } + } + + $acceptHeaders = array_merge(...$acceptHeaders); + + return implode(',', $acceptHeaders); } /** - * Return the content type based on an array of content-type provided + * Given an Accept header, returns an associative array splitting the header and its weight * - * @param string[] $contentType Array fo content-type + * @param string $header "Accept" Header * - * @return string Content-Type (e.g. application/json) + * @return array with the header and its weight */ - private function selectContentTypeHeader(array $contentType) + private function getHeaderAndWeight(string $header): array { - if (count($contentType) === 0 || (count($contentType) === 1 && $contentType[0] === '')) { - return 'application/json'; - } elseif (preg_grep("/application\/json/i", $contentType)) { - return 'application/json'; + // matches headers with weight, splitting the header and the weight in $outputArray + if (preg_match('/(.*);\s*q=(1(?:\.0+)?|0\.\d+)$/', $header, $outputArray) === 1) { + $headerData = [ + 'header' => $outputArray[1], + 'weight' => (int)($outputArray[2] * 1000), + ]; } else { - return implode(',', $contentType); + $headerData = [ + 'header' => trim($header), + 'weight' => 1000, + ]; + } + + return $headerData; + } + + /** + * @param array[] $headers + * @return string[] array of adjusted "Accept" headers + */ + private function adjustWeight(array $headers, float &$currentWeight, bool $hasMoreThan28Headers): array + { + usort($headers, function (array $a, array $b) { + return $b['weight'] - $a['weight']; + }); + + $acceptHeaders = []; + foreach ($headers as $index => $header) { + if ($index > 0 && $headers[$index - 1]['weight'] > $header['weight']) { + $currentWeight = $this->getNextWeight($currentWeight, $hasMoreThan28Headers); + } + + $weight = $currentWeight; + + $acceptHeaders[] = $this->buildAcceptHeader($header['header'], $weight); + } + + $currentWeight = $this->getNextWeight($currentWeight, $hasMoreThan28Headers); + + return $acceptHeaders; + } + + private function buildAcceptHeader(string $header, int $weight): string + { + if ($weight === 1000) { + return $header; + } + + return trim($header, '; ') . ';q=' . rtrim(sprintf('%0.3f', $weight / 1000), '0'); + } + + /** + * Calculate the next weight, based on the current one. + * + * If there are less than 28 "Accept" headers, the weights will be decreased by 1 on its highest significant digit, using the + * following formula: + * + * next weight = current weight - 10 ^ (floor(log(current weight - 1))) + * + * ( current weight minus ( 10 raised to the power of ( floor of (log to the base 10 of ( current weight minus 1 ) ) ) ) ) + * + * Starting from 1000, this generates the following series: + * + * 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 + * + * The resulting quality codes are closer to the average "normal" usage of them (like "q=0.9", "q=0.8" and so on), but it only works + * if there is a maximum of 28 "Accept" headers. If we have more than that (which is extremely unlikely), then we fall back to a 1-by-1 + * decrement rule, which will result in quality codes like "q=0.999", "q=0.998" etc. + * + * @param int $currentWeight varying from 1 to 1000 (will be divided by 1000 to build the quality value) + */ + public function getNextWeight(int $currentWeight, bool $hasMoreThan28Headers): int + { + if ($currentWeight <= 1) { + return 1; } + + if ($hasMoreThan28Headers) { + return $currentWeight - 1; + } + + return $currentWeight - 10 ** floor(log10($currentWeight - 1)); } } diff --git a/sdks/php/src/Model/AccountCreateRequest.php b/sdks/php/src/Model/AccountCreateRequest.php index 299eefa02..f4b927310 100644 --- a/sdks/php/src/Model/AccountCreateRequest.php +++ b/sdks/php/src/Model/AccountCreateRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * AccountCreateRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class AccountCreateRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -80,6 +77,25 @@ class AccountCreateRequest implements ModelInterface, ArrayAccess, JsonSerializa 'locale' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'email_address' => false, + 'client_id' => false, + 'client_secret' => false, + 'locale' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -100,6 +116,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -181,40 +241,58 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['email_address'] = $data['email_address'] ?? null; - $this->container['client_id'] = $data['client_id'] ?? null; - $this->container['client_secret'] = $data['client_secret'] ?? null; - $this->container['locale'] = $data['locale'] ?? null; + $this->setIfExists('email_address', $data ?? [], null); + $this->setIfExists('client_id', $data ?? [], null); + $this->setIfExists('client_secret', $data ?? [], null); + $this->setIfExists('locale', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): AccountCreateRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): AccountCreateRequest { - /** @var AccountCreateRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var AccountCreateRequest */ + return ObjectSerializer::deserialize( $data, AccountCreateRequest::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -229,7 +307,6 @@ public function listInvalidProperties() if ($this->container['email_address'] === null) { $invalidProperties[] = "'email_address' can't be null"; } - return $invalidProperties; } @@ -263,6 +340,9 @@ public function getEmailAddress() */ public function setEmailAddress(string $email_address) { + if (is_null($email_address)) { + throw new InvalidArgumentException('non-nullable email_address cannot be null'); + } $this->container['email_address'] = $email_address; return $this; @@ -287,6 +367,9 @@ public function getClientId() */ public function setClientId(?string $client_id) { + if (is_null($client_id)) { + throw new InvalidArgumentException('non-nullable client_id cannot be null'); + } $this->container['client_id'] = $client_id; return $this; @@ -311,6 +394,9 @@ public function getClientSecret() */ public function setClientSecret(?string $client_secret) { + if (is_null($client_secret)) { + throw new InvalidArgumentException('non-nullable client_secret cannot be null'); + } $this->container['client_secret'] = $client_secret; return $this; @@ -335,6 +421,9 @@ public function getLocale() */ public function setLocale(?string $locale) { + if (is_null($locale)) { + throw new InvalidArgumentException('non-nullable locale cannot be null'); + } $this->container['locale'] = $locale; return $this; @@ -343,12 +432,10 @@ public function setLocale(?string $locale) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -356,7 +443,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -369,13 +456,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -387,12 +472,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -401,8 +484,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/AccountCreateResponse.php b/sdks/php/src/Model/AccountCreateResponse.php index 931e9cd7f..c32d7c867 100644 --- a/sdks/php/src/Model/AccountCreateResponse.php +++ b/sdks/php/src/Model/AccountCreateResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * AccountCreateResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class AccountCreateResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -79,6 +75,24 @@ class AccountCreateResponse implements ModelInterface, ArrayAccess, JsonSerializ 'warnings' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'account' => false, + 'oauth_data' => false, + 'warnings' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -99,6 +113,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -177,39 +235,57 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['account'] = $data['account'] ?? null; - $this->container['oauth_data'] = $data['oauth_data'] ?? null; - $this->container['warnings'] = $data['warnings'] ?? null; + $this->setIfExists('account', $data ?? [], null); + $this->setIfExists('oauth_data', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): AccountCreateResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): AccountCreateResponse { - /** @var AccountCreateResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var AccountCreateResponse */ + return ObjectSerializer::deserialize( $data, AccountCreateResponse::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -219,9 +295,7 @@ public static function init(array $data): AccountCreateResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -254,6 +328,9 @@ public function getAccount() */ public function setAccount(?AccountResponse $account) { + if (is_null($account)) { + throw new InvalidArgumentException('non-nullable account cannot be null'); + } $this->container['account'] = $account; return $this; @@ -278,6 +355,9 @@ public function getOauthData() */ public function setOauthData(?OAuthTokenResponse $oauth_data) { + if (is_null($oauth_data)) { + throw new InvalidArgumentException('non-nullable oauth_data cannot be null'); + } $this->container['oauth_data'] = $oauth_data; return $this; @@ -302,6 +382,9 @@ public function getWarnings() */ public function setWarnings(?array $warnings) { + if (is_null($warnings)) { + throw new InvalidArgumentException('non-nullable warnings cannot be null'); + } $this->container['warnings'] = $warnings; return $this; @@ -310,12 +393,10 @@ public function setWarnings(?array $warnings) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -323,7 +404,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -336,13 +417,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -354,12 +433,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -368,8 +445,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/AccountGetResponse.php b/sdks/php/src/Model/AccountGetResponse.php index d572c01fb..84ef80142 100644 --- a/sdks/php/src/Model/AccountGetResponse.php +++ b/sdks/php/src/Model/AccountGetResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * AccountGetResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class AccountGetResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -77,6 +73,23 @@ class AccountGetResponse implements ModelInterface, ArrayAccess, JsonSerializabl 'warnings' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'account' => false, + 'warnings' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -97,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -172,38 +229,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['account'] = $data['account'] ?? null; - $this->container['warnings'] = $data['warnings'] ?? null; + $this->setIfExists('account', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): AccountGetResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): AccountGetResponse { - /** @var AccountGetResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var AccountGetResponse */ + return ObjectSerializer::deserialize( $data, AccountGetResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -213,9 +288,7 @@ public static function init(array $data): AccountGetResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -248,6 +321,9 @@ public function getAccount() */ public function setAccount(?AccountResponse $account) { + if (is_null($account)) { + throw new InvalidArgumentException('non-nullable account cannot be null'); + } $this->container['account'] = $account; return $this; @@ -272,6 +348,9 @@ public function getWarnings() */ public function setWarnings(?array $warnings) { + if (is_null($warnings)) { + throw new InvalidArgumentException('non-nullable warnings cannot be null'); + } $this->container['warnings'] = $warnings; return $this; @@ -280,12 +359,10 @@ public function setWarnings(?array $warnings) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -293,7 +370,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -306,13 +383,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -324,12 +399,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -338,8 +411,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/AccountResponse.php b/sdks/php/src/Model/AccountResponse.php index e9089384d..3fb1a1869 100644 --- a/sdks/php/src/Model/AccountResponse.php +++ b/sdks/php/src/Model/AccountResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * AccountResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class AccountResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -95,6 +91,32 @@ class AccountResponse implements ModelInterface, ArrayAccess, JsonSerializable 'usage' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'account_id' => false, + 'email_address' => false, + 'is_locked' => false, + 'is_paid_hs' => false, + 'is_paid_hf' => false, + 'quotas' => false, + 'callback_url' => true, + 'role_code' => true, + 'team_id' => true, + 'locale' => true, + 'usage' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -115,6 +137,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -217,47 +283,65 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['account_id'] = $data['account_id'] ?? null; - $this->container['email_address'] = $data['email_address'] ?? null; - $this->container['is_locked'] = $data['is_locked'] ?? null; - $this->container['is_paid_hs'] = $data['is_paid_hs'] ?? null; - $this->container['is_paid_hf'] = $data['is_paid_hf'] ?? null; - $this->container['quotas'] = $data['quotas'] ?? null; - $this->container['callback_url'] = $data['callback_url'] ?? null; - $this->container['role_code'] = $data['role_code'] ?? null; - $this->container['team_id'] = $data['team_id'] ?? null; - $this->container['locale'] = $data['locale'] ?? null; - $this->container['usage'] = $data['usage'] ?? null; + $this->setIfExists('account_id', $data ?? [], null); + $this->setIfExists('email_address', $data ?? [], null); + $this->setIfExists('is_locked', $data ?? [], null); + $this->setIfExists('is_paid_hs', $data ?? [], null); + $this->setIfExists('is_paid_hf', $data ?? [], null); + $this->setIfExists('quotas', $data ?? [], null); + $this->setIfExists('callback_url', $data ?? [], null); + $this->setIfExists('role_code', $data ?? [], null); + $this->setIfExists('team_id', $data ?? [], null); + $this->setIfExists('locale', $data ?? [], null); + $this->setIfExists('usage', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): AccountResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): AccountResponse { - /** @var AccountResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var AccountResponse */ + return ObjectSerializer::deserialize( $data, AccountResponse::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -267,9 +351,7 @@ public static function init(array $data): AccountResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -302,6 +384,9 @@ public function getAccountId() */ public function setAccountId(?string $account_id) { + if (is_null($account_id)) { + throw new InvalidArgumentException('non-nullable account_id cannot be null'); + } $this->container['account_id'] = $account_id; return $this; @@ -326,6 +411,9 @@ public function getEmailAddress() */ public function setEmailAddress(?string $email_address) { + if (is_null($email_address)) { + throw new InvalidArgumentException('non-nullable email_address cannot be null'); + } $this->container['email_address'] = $email_address; return $this; @@ -350,6 +438,9 @@ public function getIsLocked() */ public function setIsLocked(?bool $is_locked) { + if (is_null($is_locked)) { + throw new InvalidArgumentException('non-nullable is_locked cannot be null'); + } $this->container['is_locked'] = $is_locked; return $this; @@ -374,6 +465,9 @@ public function getIsPaidHs() */ public function setIsPaidHs(?bool $is_paid_hs) { + if (is_null($is_paid_hs)) { + throw new InvalidArgumentException('non-nullable is_paid_hs cannot be null'); + } $this->container['is_paid_hs'] = $is_paid_hs; return $this; @@ -398,6 +492,9 @@ public function getIsPaidHf() */ public function setIsPaidHf(?bool $is_paid_hf) { + if (is_null($is_paid_hf)) { + throw new InvalidArgumentException('non-nullable is_paid_hf cannot be null'); + } $this->container['is_paid_hf'] = $is_paid_hf; return $this; @@ -422,6 +519,9 @@ public function getQuotas() */ public function setQuotas(?AccountResponseQuotas $quotas) { + if (is_null($quotas)) { + throw new InvalidArgumentException('non-nullable quotas cannot be null'); + } $this->container['quotas'] = $quotas; return $this; @@ -446,6 +546,16 @@ public function getCallbackUrl() */ public function setCallbackUrl(?string $callback_url) { + if (is_null($callback_url)) { + array_push($this->openAPINullablesSetToNull, 'callback_url'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('callback_url', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['callback_url'] = $callback_url; return $this; @@ -470,6 +580,16 @@ public function getRoleCode() */ public function setRoleCode(?string $role_code) { + if (is_null($role_code)) { + array_push($this->openAPINullablesSetToNull, 'role_code'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('role_code', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['role_code'] = $role_code; return $this; @@ -494,6 +614,16 @@ public function getTeamId() */ public function setTeamId(?string $team_id) { + if (is_null($team_id)) { + array_push($this->openAPINullablesSetToNull, 'team_id'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('team_id', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['team_id'] = $team_id; return $this; @@ -518,6 +648,16 @@ public function getLocale() */ public function setLocale(?string $locale) { + if (is_null($locale)) { + array_push($this->openAPINullablesSetToNull, 'locale'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('locale', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['locale'] = $locale; return $this; @@ -542,6 +682,9 @@ public function getUsage() */ public function setUsage(?AccountResponseUsage $usage) { + if (is_null($usage)) { + throw new InvalidArgumentException('non-nullable usage cannot be null'); + } $this->container['usage'] = $usage; return $this; @@ -550,12 +693,10 @@ public function setUsage(?AccountResponseUsage $usage) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -563,7 +704,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -576,13 +717,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -594,12 +733,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -608,8 +745,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/AccountResponseQuotas.php b/sdks/php/src/Model/AccountResponseQuotas.php index cccd306d1..3ec8d7a9e 100644 --- a/sdks/php/src/Model/AccountResponseQuotas.php +++ b/sdks/php/src/Model/AccountResponseQuotas.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -38,12 +37,8 @@ * * @category Class * @description Details concerning remaining monthly quotas. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class AccountResponseQuotas implements ModelInterface, ArrayAccess, JsonSerializable { @@ -86,6 +81,27 @@ class AccountResponseQuotas implements ModelInterface, ArrayAccess, JsonSerializ 'num_fax_pages_left' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'api_signature_requests_left' => true, + 'documents_left' => true, + 'templates_total' => true, + 'templates_left' => true, + 'sms_verifications_left' => true, + 'num_fax_pages_left' => true, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -106,6 +122,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -193,42 +253,60 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['api_signature_requests_left'] = $data['api_signature_requests_left'] ?? null; - $this->container['documents_left'] = $data['documents_left'] ?? null; - $this->container['templates_total'] = $data['templates_total'] ?? null; - $this->container['templates_left'] = $data['templates_left'] ?? null; - $this->container['sms_verifications_left'] = $data['sms_verifications_left'] ?? null; - $this->container['num_fax_pages_left'] = $data['num_fax_pages_left'] ?? null; + $this->setIfExists('api_signature_requests_left', $data ?? [], null); + $this->setIfExists('documents_left', $data ?? [], null); + $this->setIfExists('templates_total', $data ?? [], null); + $this->setIfExists('templates_left', $data ?? [], null); + $this->setIfExists('sms_verifications_left', $data ?? [], null); + $this->setIfExists('num_fax_pages_left', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): AccountResponseQuotas { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): AccountResponseQuotas { - /** @var AccountResponseQuotas $obj */ - $obj = ObjectSerializer::deserialize( + /** @var AccountResponseQuotas */ + return ObjectSerializer::deserialize( $data, AccountResponseQuotas::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -238,9 +316,7 @@ public static function init(array $data): AccountResponseQuotas */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -273,6 +349,16 @@ public function getApiSignatureRequestsLeft() */ public function setApiSignatureRequestsLeft(?int $api_signature_requests_left) { + if (is_null($api_signature_requests_left)) { + array_push($this->openAPINullablesSetToNull, 'api_signature_requests_left'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('api_signature_requests_left', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['api_signature_requests_left'] = $api_signature_requests_left; return $this; @@ -297,6 +383,16 @@ public function getDocumentsLeft() */ public function setDocumentsLeft(?int $documents_left) { + if (is_null($documents_left)) { + array_push($this->openAPINullablesSetToNull, 'documents_left'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('documents_left', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['documents_left'] = $documents_left; return $this; @@ -321,6 +417,16 @@ public function getTemplatesTotal() */ public function setTemplatesTotal(?int $templates_total) { + if (is_null($templates_total)) { + array_push($this->openAPINullablesSetToNull, 'templates_total'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('templates_total', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['templates_total'] = $templates_total; return $this; @@ -345,6 +451,16 @@ public function getTemplatesLeft() */ public function setTemplatesLeft(?int $templates_left) { + if (is_null($templates_left)) { + array_push($this->openAPINullablesSetToNull, 'templates_left'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('templates_left', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['templates_left'] = $templates_left; return $this; @@ -369,6 +485,16 @@ public function getSmsVerificationsLeft() */ public function setSmsVerificationsLeft(?int $sms_verifications_left) { + if (is_null($sms_verifications_left)) { + array_push($this->openAPINullablesSetToNull, 'sms_verifications_left'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('sms_verifications_left', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['sms_verifications_left'] = $sms_verifications_left; return $this; @@ -393,6 +519,16 @@ public function getNumFaxPagesLeft() */ public function setNumFaxPagesLeft(?int $num_fax_pages_left) { + if (is_null($num_fax_pages_left)) { + array_push($this->openAPINullablesSetToNull, 'num_fax_pages_left'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('num_fax_pages_left', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['num_fax_pages_left'] = $num_fax_pages_left; return $this; @@ -401,12 +537,10 @@ public function setNumFaxPagesLeft(?int $num_fax_pages_left) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -414,7 +548,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -427,13 +561,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -445,12 +577,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -459,8 +589,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/AccountResponseUsage.php b/sdks/php/src/Model/AccountResponseUsage.php index 847becac0..94eb509e7 100644 --- a/sdks/php/src/Model/AccountResponseUsage.php +++ b/sdks/php/src/Model/AccountResponseUsage.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -38,12 +37,8 @@ * * @category Class * @description Details concerning monthly usage - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class AccountResponseUsage implements ModelInterface, ArrayAccess, JsonSerializable { @@ -76,6 +71,22 @@ class AccountResponseUsage implements ModelInterface, ArrayAccess, JsonSerializa 'fax_pages_sent' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'fax_pages_sent' => true, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -96,6 +107,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -168,37 +223,55 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['fax_pages_sent'] = $data['fax_pages_sent'] ?? null; + $this->setIfExists('fax_pages_sent', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): AccountResponseUsage { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): AccountResponseUsage { - /** @var AccountResponseUsage $obj */ - $obj = ObjectSerializer::deserialize( + /** @var AccountResponseUsage */ + return ObjectSerializer::deserialize( $data, AccountResponseUsage::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -208,9 +281,7 @@ public static function init(array $data): AccountResponseUsage */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -243,6 +314,16 @@ public function getFaxPagesSent() */ public function setFaxPagesSent(?int $fax_pages_sent) { + if (is_null($fax_pages_sent)) { + array_push($this->openAPINullablesSetToNull, 'fax_pages_sent'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('fax_pages_sent', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['fax_pages_sent'] = $fax_pages_sent; return $this; @@ -251,12 +332,10 @@ public function setFaxPagesSent(?int $fax_pages_sent) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -264,7 +343,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -277,13 +356,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -295,12 +372,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -309,8 +384,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/AccountUpdateRequest.php b/sdks/php/src/Model/AccountUpdateRequest.php index 9eb908f5b..34a65c498 100644 --- a/sdks/php/src/Model/AccountUpdateRequest.php +++ b/sdks/php/src/Model/AccountUpdateRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * AccountUpdateRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class AccountUpdateRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -78,6 +75,24 @@ class AccountUpdateRequest implements ModelInterface, ArrayAccess, JsonSerializa 'locale' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'account_id' => true, + 'callback_url' => false, + 'locale' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -98,6 +113,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -176,39 +235,57 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['account_id'] = $data['account_id'] ?? null; - $this->container['callback_url'] = $data['callback_url'] ?? null; - $this->container['locale'] = $data['locale'] ?? null; + $this->setIfExists('account_id', $data ?? [], null); + $this->setIfExists('callback_url', $data ?? [], null); + $this->setIfExists('locale', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): AccountUpdateRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): AccountUpdateRequest { - /** @var AccountUpdateRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var AccountUpdateRequest */ + return ObjectSerializer::deserialize( $data, AccountUpdateRequest::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -218,9 +295,7 @@ public static function init(array $data): AccountUpdateRequest */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -253,6 +328,16 @@ public function getAccountId() */ public function setAccountId(?string $account_id) { + if (is_null($account_id)) { + array_push($this->openAPINullablesSetToNull, 'account_id'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('account_id', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['account_id'] = $account_id; return $this; @@ -277,6 +362,9 @@ public function getCallbackUrl() */ public function setCallbackUrl(?string $callback_url) { + if (is_null($callback_url)) { + throw new InvalidArgumentException('non-nullable callback_url cannot be null'); + } $this->container['callback_url'] = $callback_url; return $this; @@ -301,6 +389,9 @@ public function getLocale() */ public function setLocale(?string $locale) { + if (is_null($locale)) { + throw new InvalidArgumentException('non-nullable locale cannot be null'); + } $this->container['locale'] = $locale; return $this; @@ -309,12 +400,10 @@ public function setLocale(?string $locale) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -322,7 +411,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -335,13 +424,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -353,12 +440,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -367,8 +452,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/AccountVerifyRequest.php b/sdks/php/src/Model/AccountVerifyRequest.php index 123cb57b2..d8731ea40 100644 --- a/sdks/php/src/Model/AccountVerifyRequest.php +++ b/sdks/php/src/Model/AccountVerifyRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * AccountVerifyRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class AccountVerifyRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -74,6 +71,22 @@ class AccountVerifyRequest implements ModelInterface, ArrayAccess, JsonSerializa 'email_address' => 'email', ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'email_address' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -94,6 +107,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -166,37 +223,55 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['email_address'] = $data['email_address'] ?? null; + $this->setIfExists('email_address', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): AccountVerifyRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): AccountVerifyRequest { - /** @var AccountVerifyRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var AccountVerifyRequest */ + return ObjectSerializer::deserialize( $data, AccountVerifyRequest::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -211,7 +286,6 @@ public function listInvalidProperties() if ($this->container['email_address'] === null) { $invalidProperties[] = "'email_address' can't be null"; } - return $invalidProperties; } @@ -245,6 +319,9 @@ public function getEmailAddress() */ public function setEmailAddress(string $email_address) { + if (is_null($email_address)) { + throw new InvalidArgumentException('non-nullable email_address cannot be null'); + } $this->container['email_address'] = $email_address; return $this; @@ -253,12 +330,10 @@ public function setEmailAddress(string $email_address) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -266,7 +341,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -279,13 +354,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -297,12 +370,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -311,8 +382,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/AccountVerifyResponse.php b/sdks/php/src/Model/AccountVerifyResponse.php index 51983c5de..f8f6a65e5 100644 --- a/sdks/php/src/Model/AccountVerifyResponse.php +++ b/sdks/php/src/Model/AccountVerifyResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * AccountVerifyResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class AccountVerifyResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -77,6 +73,23 @@ class AccountVerifyResponse implements ModelInterface, ArrayAccess, JsonSerializ 'warnings' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'account' => false, + 'warnings' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -97,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -172,38 +229,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['account'] = $data['account'] ?? null; - $this->container['warnings'] = $data['warnings'] ?? null; + $this->setIfExists('account', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): AccountVerifyResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): AccountVerifyResponse { - /** @var AccountVerifyResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var AccountVerifyResponse */ + return ObjectSerializer::deserialize( $data, AccountVerifyResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -213,9 +288,7 @@ public static function init(array $data): AccountVerifyResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -248,6 +321,9 @@ public function getAccount() */ public function setAccount(?AccountVerifyResponseAccount $account) { + if (is_null($account)) { + throw new InvalidArgumentException('non-nullable account cannot be null'); + } $this->container['account'] = $account; return $this; @@ -272,6 +348,9 @@ public function getWarnings() */ public function setWarnings(?array $warnings) { + if (is_null($warnings)) { + throw new InvalidArgumentException('non-nullable warnings cannot be null'); + } $this->container['warnings'] = $warnings; return $this; @@ -280,12 +359,10 @@ public function setWarnings(?array $warnings) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -293,7 +370,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -306,13 +383,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -324,12 +399,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -338,8 +411,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/AccountVerifyResponseAccount.php b/sdks/php/src/Model/AccountVerifyResponseAccount.php index 1e045182f..34a1de5e9 100644 --- a/sdks/php/src/Model/AccountVerifyResponseAccount.php +++ b/sdks/php/src/Model/AccountVerifyResponseAccount.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * AccountVerifyResponseAccount Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class AccountVerifyResponseAccount implements ModelInterface, ArrayAccess, JsonSerializable { @@ -75,6 +71,22 @@ class AccountVerifyResponseAccount implements ModelInterface, ArrayAccess, JsonS 'email_address' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'email_address' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -95,6 +107,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -167,37 +223,55 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['email_address'] = $data['email_address'] ?? null; + $this->setIfExists('email_address', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): AccountVerifyResponseAccount { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): AccountVerifyResponseAccount { - /** @var AccountVerifyResponseAccount $obj */ - $obj = ObjectSerializer::deserialize( + /** @var AccountVerifyResponseAccount */ + return ObjectSerializer::deserialize( $data, AccountVerifyResponseAccount::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -207,9 +281,7 @@ public static function init(array $data): AccountVerifyResponseAccount */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -242,6 +314,9 @@ public function getEmailAddress() */ public function setEmailAddress(?string $email_address) { + if (is_null($email_address)) { + throw new InvalidArgumentException('non-nullable email_address cannot be null'); + } $this->container['email_address'] = $email_address; return $this; @@ -250,12 +325,10 @@ public function setEmailAddress(?string $email_address) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -263,7 +336,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -276,13 +349,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -294,12 +365,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -308,8 +377,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/ApiAppCreateRequest.php b/sdks/php/src/Model/ApiAppCreateRequest.php index c863aad89..d31444091 100644 --- a/sdks/php/src/Model/ApiAppCreateRequest.php +++ b/sdks/php/src/Model/ApiAppCreateRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -39,11 +38,8 @@ * ApiAppCreateRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class ApiAppCreateRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -88,6 +84,28 @@ class ApiAppCreateRequest implements ModelInterface, ArrayAccess, JsonSerializab 'white_labeling_options' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'domains' => false, + 'name' => false, + 'callback_url' => false, + 'custom_logo_file' => false, + 'oauth' => false, + 'options' => false, + 'white_labeling_options' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -108,6 +126,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -198,43 +260,61 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['domains'] = $data['domains'] ?? null; - $this->container['name'] = $data['name'] ?? null; - $this->container['callback_url'] = $data['callback_url'] ?? null; - $this->container['custom_logo_file'] = $data['custom_logo_file'] ?? null; - $this->container['oauth'] = $data['oauth'] ?? null; - $this->container['options'] = $data['options'] ?? null; - $this->container['white_labeling_options'] = $data['white_labeling_options'] ?? null; + $this->setIfExists('domains', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('callback_url', $data ?? [], null); + $this->setIfExists('custom_logo_file', $data ?? [], null); + $this->setIfExists('oauth', $data ?? [], null); + $this->setIfExists('options', $data ?? [], null); + $this->setIfExists('white_labeling_options', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): ApiAppCreateRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): ApiAppCreateRequest { - /** @var ApiAppCreateRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var ApiAppCreateRequest */ + return ObjectSerializer::deserialize( $data, ApiAppCreateRequest::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -249,18 +329,17 @@ public function listInvalidProperties() if ($this->container['domains'] === null) { $invalidProperties[] = "'domains' can't be null"; } - if ((count($this->container['domains']) > 2)) { + if (count($this->container['domains']) > 2) { $invalidProperties[] = "invalid value for 'domains', number of items must be less than or equal to 2."; } - if ((count($this->container['domains']) < 1)) { + if (count($this->container['domains']) < 1) { $invalidProperties[] = "invalid value for 'domains', number of items must be greater than or equal to 1."; } if ($this->container['name'] === null) { $invalidProperties[] = "'name' can't be null"; } - return $invalidProperties; } @@ -294,10 +373,14 @@ public function getDomains() */ public function setDomains(array $domains) { - if ((count($domains) > 2)) { + if (is_null($domains)) { + throw new InvalidArgumentException('non-nullable domains cannot be null'); + } + + if (count($domains) > 2) { throw new InvalidArgumentException('invalid value for $domains when calling ApiAppCreateRequest., number of items must be less than or equal to 2.'); } - if ((count($domains) < 1)) { + if (count($domains) < 1) { throw new InvalidArgumentException('invalid length for $domains when calling ApiAppCreateRequest., number of items must be greater than or equal to 1.'); } $this->container['domains'] = $domains; @@ -324,6 +407,9 @@ public function getName() */ public function setName(string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -348,6 +434,9 @@ public function getCallbackUrl() */ public function setCallbackUrl(?string $callback_url) { + if (is_null($callback_url)) { + throw new InvalidArgumentException('non-nullable callback_url cannot be null'); + } $this->container['callback_url'] = $callback_url; return $this; @@ -372,6 +461,9 @@ public function getCustomLogoFile() */ public function setCustomLogoFile(?SplFileObject $custom_logo_file) { + if (is_null($custom_logo_file)) { + throw new InvalidArgumentException('non-nullable custom_logo_file cannot be null'); + } $this->container['custom_logo_file'] = $custom_logo_file; return $this; @@ -396,6 +488,9 @@ public function getOauth() */ public function setOauth(?SubOAuth $oauth) { + if (is_null($oauth)) { + throw new InvalidArgumentException('non-nullable oauth cannot be null'); + } $this->container['oauth'] = $oauth; return $this; @@ -420,6 +515,9 @@ public function getOptions() */ public function setOptions(?SubOptions $options) { + if (is_null($options)) { + throw new InvalidArgumentException('non-nullable options cannot be null'); + } $this->container['options'] = $options; return $this; @@ -444,6 +542,9 @@ public function getWhiteLabelingOptions() */ public function setWhiteLabelingOptions(?SubWhiteLabelingOptions $white_labeling_options) { + if (is_null($white_labeling_options)) { + throw new InvalidArgumentException('non-nullable white_labeling_options cannot be null'); + } $this->container['white_labeling_options'] = $white_labeling_options; return $this; @@ -452,12 +553,10 @@ public function setWhiteLabelingOptions(?SubWhiteLabelingOptions $white_labeling /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -465,7 +564,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -478,13 +577,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -496,12 +593,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -510,8 +605,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/ApiAppGetResponse.php b/sdks/php/src/Model/ApiAppGetResponse.php index 7314d7b04..0507cd879 100644 --- a/sdks/php/src/Model/ApiAppGetResponse.php +++ b/sdks/php/src/Model/ApiAppGetResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * ApiAppGetResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class ApiAppGetResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -77,6 +73,23 @@ class ApiAppGetResponse implements ModelInterface, ArrayAccess, JsonSerializable 'warnings' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'api_app' => false, + 'warnings' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -97,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -172,38 +229,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['api_app'] = $data['api_app'] ?? null; - $this->container['warnings'] = $data['warnings'] ?? null; + $this->setIfExists('api_app', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): ApiAppGetResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): ApiAppGetResponse { - /** @var ApiAppGetResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var ApiAppGetResponse */ + return ObjectSerializer::deserialize( $data, ApiAppGetResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -213,9 +288,7 @@ public static function init(array $data): ApiAppGetResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -248,6 +321,9 @@ public function getApiApp() */ public function setApiApp(?ApiAppResponse $api_app) { + if (is_null($api_app)) { + throw new InvalidArgumentException('non-nullable api_app cannot be null'); + } $this->container['api_app'] = $api_app; return $this; @@ -272,6 +348,9 @@ public function getWarnings() */ public function setWarnings(?array $warnings) { + if (is_null($warnings)) { + throw new InvalidArgumentException('non-nullable warnings cannot be null'); + } $this->container['warnings'] = $warnings; return $this; @@ -280,12 +359,10 @@ public function setWarnings(?array $warnings) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -293,7 +370,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -306,13 +383,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -324,12 +399,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -338,8 +411,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/ApiAppListResponse.php b/sdks/php/src/Model/ApiAppListResponse.php index c795f6428..81b33b826 100644 --- a/sdks/php/src/Model/ApiAppListResponse.php +++ b/sdks/php/src/Model/ApiAppListResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * ApiAppListResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class ApiAppListResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -79,6 +75,24 @@ class ApiAppListResponse implements ModelInterface, ArrayAccess, JsonSerializabl 'warnings' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'api_apps' => false, + 'list_info' => false, + 'warnings' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -99,6 +113,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -177,39 +235,57 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['api_apps'] = $data['api_apps'] ?? null; - $this->container['list_info'] = $data['list_info'] ?? null; - $this->container['warnings'] = $data['warnings'] ?? null; + $this->setIfExists('api_apps', $data ?? [], null); + $this->setIfExists('list_info', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): ApiAppListResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): ApiAppListResponse { - /** @var ApiAppListResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var ApiAppListResponse */ + return ObjectSerializer::deserialize( $data, ApiAppListResponse::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -219,9 +295,7 @@ public static function init(array $data): ApiAppListResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -254,6 +328,9 @@ public function getApiApps() */ public function setApiApps(?array $api_apps) { + if (is_null($api_apps)) { + throw new InvalidArgumentException('non-nullable api_apps cannot be null'); + } $this->container['api_apps'] = $api_apps; return $this; @@ -278,6 +355,9 @@ public function getListInfo() */ public function setListInfo(?ListInfoResponse $list_info) { + if (is_null($list_info)) { + throw new InvalidArgumentException('non-nullable list_info cannot be null'); + } $this->container['list_info'] = $list_info; return $this; @@ -302,6 +382,9 @@ public function getWarnings() */ public function setWarnings(?array $warnings) { + if (is_null($warnings)) { + throw new InvalidArgumentException('non-nullable warnings cannot be null'); + } $this->container['warnings'] = $warnings; return $this; @@ -310,12 +393,10 @@ public function setWarnings(?array $warnings) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -323,7 +404,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -336,13 +417,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -354,12 +433,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -368,8 +445,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/ApiAppResponse.php b/sdks/php/src/Model/ApiAppResponse.php index cbc677357..3e214031d 100644 --- a/sdks/php/src/Model/ApiAppResponse.php +++ b/sdks/php/src/Model/ApiAppResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,12 +38,8 @@ * * @category Class * @description Contains information about an API App. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class ApiAppResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -94,6 +90,31 @@ class ApiAppResponse implements ModelInterface, ArrayAccess, JsonSerializable 'white_labeling_options' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'callback_url' => true, + 'client_id' => false, + 'created_at' => false, + 'domains' => false, + 'name' => false, + 'is_approved' => false, + 'oauth' => true, + 'options' => true, + 'owner_account' => false, + 'white_labeling_options' => true, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -114,6 +135,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -213,46 +278,64 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['callback_url'] = $data['callback_url'] ?? null; - $this->container['client_id'] = $data['client_id'] ?? null; - $this->container['created_at'] = $data['created_at'] ?? null; - $this->container['domains'] = $data['domains'] ?? null; - $this->container['name'] = $data['name'] ?? null; - $this->container['is_approved'] = $data['is_approved'] ?? null; - $this->container['oauth'] = $data['oauth'] ?? null; - $this->container['options'] = $data['options'] ?? null; - $this->container['owner_account'] = $data['owner_account'] ?? null; - $this->container['white_labeling_options'] = $data['white_labeling_options'] ?? null; + $this->setIfExists('callback_url', $data ?? [], null); + $this->setIfExists('client_id', $data ?? [], null); + $this->setIfExists('created_at', $data ?? [], null); + $this->setIfExists('domains', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('is_approved', $data ?? [], null); + $this->setIfExists('oauth', $data ?? [], null); + $this->setIfExists('options', $data ?? [], null); + $this->setIfExists('owner_account', $data ?? [], null); + $this->setIfExists('white_labeling_options', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): ApiAppResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): ApiAppResponse { - /** @var ApiAppResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var ApiAppResponse */ + return ObjectSerializer::deserialize( $data, ApiAppResponse::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -262,9 +345,7 @@ public static function init(array $data): ApiAppResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -297,6 +378,16 @@ public function getCallbackUrl() */ public function setCallbackUrl(?string $callback_url) { + if (is_null($callback_url)) { + array_push($this->openAPINullablesSetToNull, 'callback_url'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('callback_url', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['callback_url'] = $callback_url; return $this; @@ -321,6 +412,9 @@ public function getClientId() */ public function setClientId(?string $client_id) { + if (is_null($client_id)) { + throw new InvalidArgumentException('non-nullable client_id cannot be null'); + } $this->container['client_id'] = $client_id; return $this; @@ -345,6 +439,9 @@ public function getCreatedAt() */ public function setCreatedAt(?int $created_at) { + if (is_null($created_at)) { + throw new InvalidArgumentException('non-nullable created_at cannot be null'); + } $this->container['created_at'] = $created_at; return $this; @@ -369,6 +466,9 @@ public function getDomains() */ public function setDomains(?array $domains) { + if (is_null($domains)) { + throw new InvalidArgumentException('non-nullable domains cannot be null'); + } $this->container['domains'] = $domains; return $this; @@ -393,6 +493,9 @@ public function getName() */ public function setName(?string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -417,6 +520,9 @@ public function getIsApproved() */ public function setIsApproved(?bool $is_approved) { + if (is_null($is_approved)) { + throw new InvalidArgumentException('non-nullable is_approved cannot be null'); + } $this->container['is_approved'] = $is_approved; return $this; @@ -441,6 +547,16 @@ public function getOauth() */ public function setOauth(?ApiAppResponseOAuth $oauth) { + if (is_null($oauth)) { + array_push($this->openAPINullablesSetToNull, 'oauth'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('oauth', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['oauth'] = $oauth; return $this; @@ -465,6 +581,16 @@ public function getOptions() */ public function setOptions(?ApiAppResponseOptions $options) { + if (is_null($options)) { + array_push($this->openAPINullablesSetToNull, 'options'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('options', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['options'] = $options; return $this; @@ -489,6 +615,9 @@ public function getOwnerAccount() */ public function setOwnerAccount(?ApiAppResponseOwnerAccount $owner_account) { + if (is_null($owner_account)) { + throw new InvalidArgumentException('non-nullable owner_account cannot be null'); + } $this->container['owner_account'] = $owner_account; return $this; @@ -513,6 +642,16 @@ public function getWhiteLabelingOptions() */ public function setWhiteLabelingOptions(?ApiAppResponseWhiteLabelingOptions $white_labeling_options) { + if (is_null($white_labeling_options)) { + array_push($this->openAPINullablesSetToNull, 'white_labeling_options'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('white_labeling_options', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['white_labeling_options'] = $white_labeling_options; return $this; @@ -521,12 +660,10 @@ public function setWhiteLabelingOptions(?ApiAppResponseWhiteLabelingOptions $whi /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -534,7 +671,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -547,13 +684,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -565,12 +700,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -579,8 +712,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/ApiAppResponseOAuth.php b/sdks/php/src/Model/ApiAppResponseOAuth.php index 343d42211..57a61134a 100644 --- a/sdks/php/src/Model/ApiAppResponseOAuth.php +++ b/sdks/php/src/Model/ApiAppResponseOAuth.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,12 +38,8 @@ * * @category Class * @description An object describing the app's OAuth properties, or null if OAuth is not configured for the app. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class ApiAppResponseOAuth implements ModelInterface, ArrayAccess, JsonSerializable { @@ -82,6 +78,25 @@ class ApiAppResponseOAuth implements ModelInterface, ArrayAccess, JsonSerializab 'charges_users' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'callback_url' => false, + 'secret' => false, + 'scopes' => false, + 'charges_users' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -102,6 +117,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -183,40 +242,58 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['callback_url'] = $data['callback_url'] ?? null; - $this->container['secret'] = $data['secret'] ?? null; - $this->container['scopes'] = $data['scopes'] ?? null; - $this->container['charges_users'] = $data['charges_users'] ?? null; + $this->setIfExists('callback_url', $data ?? [], null); + $this->setIfExists('secret', $data ?? [], null); + $this->setIfExists('scopes', $data ?? [], null); + $this->setIfExists('charges_users', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): ApiAppResponseOAuth { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): ApiAppResponseOAuth { - /** @var ApiAppResponseOAuth $obj */ - $obj = ObjectSerializer::deserialize( + /** @var ApiAppResponseOAuth */ + return ObjectSerializer::deserialize( $data, ApiAppResponseOAuth::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -226,9 +303,7 @@ public static function init(array $data): ApiAppResponseOAuth */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -261,6 +336,9 @@ public function getCallbackUrl() */ public function setCallbackUrl(?string $callback_url) { + if (is_null($callback_url)) { + throw new InvalidArgumentException('non-nullable callback_url cannot be null'); + } $this->container['callback_url'] = $callback_url; return $this; @@ -285,6 +363,9 @@ public function getSecret() */ public function setSecret(?string $secret) { + if (is_null($secret)) { + throw new InvalidArgumentException('non-nullable secret cannot be null'); + } $this->container['secret'] = $secret; return $this; @@ -309,6 +390,9 @@ public function getScopes() */ public function setScopes(?array $scopes) { + if (is_null($scopes)) { + throw new InvalidArgumentException('non-nullable scopes cannot be null'); + } $this->container['scopes'] = $scopes; return $this; @@ -333,6 +417,9 @@ public function getChargesUsers() */ public function setChargesUsers(?bool $charges_users) { + if (is_null($charges_users)) { + throw new InvalidArgumentException('non-nullable charges_users cannot be null'); + } $this->container['charges_users'] = $charges_users; return $this; @@ -341,12 +428,10 @@ public function setChargesUsers(?bool $charges_users) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -354,7 +439,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -367,13 +452,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -385,12 +468,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -399,8 +480,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/ApiAppResponseOptions.php b/sdks/php/src/Model/ApiAppResponseOptions.php index 4e24a1f7e..99c11f02a 100644 --- a/sdks/php/src/Model/ApiAppResponseOptions.php +++ b/sdks/php/src/Model/ApiAppResponseOptions.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,12 +38,8 @@ * * @category Class * @description An object with options that override account settings. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class ApiAppResponseOptions implements ModelInterface, ArrayAccess, JsonSerializable { @@ -76,6 +72,22 @@ class ApiAppResponseOptions implements ModelInterface, ArrayAccess, JsonSerializ 'can_insert_everywhere' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'can_insert_everywhere' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -96,6 +108,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -168,37 +224,55 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['can_insert_everywhere'] = $data['can_insert_everywhere'] ?? null; + $this->setIfExists('can_insert_everywhere', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): ApiAppResponseOptions { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): ApiAppResponseOptions { - /** @var ApiAppResponseOptions $obj */ - $obj = ObjectSerializer::deserialize( + /** @var ApiAppResponseOptions */ + return ObjectSerializer::deserialize( $data, ApiAppResponseOptions::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -208,9 +282,7 @@ public static function init(array $data): ApiAppResponseOptions */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -243,6 +315,9 @@ public function getCanInsertEverywhere() */ public function setCanInsertEverywhere(?bool $can_insert_everywhere) { + if (is_null($can_insert_everywhere)) { + throw new InvalidArgumentException('non-nullable can_insert_everywhere cannot be null'); + } $this->container['can_insert_everywhere'] = $can_insert_everywhere; return $this; @@ -251,12 +326,10 @@ public function setCanInsertEverywhere(?bool $can_insert_everywhere) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -264,7 +337,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -277,13 +350,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -295,12 +366,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -309,8 +378,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/ApiAppResponseOwnerAccount.php b/sdks/php/src/Model/ApiAppResponseOwnerAccount.php index f3fb77f97..ffc120960 100644 --- a/sdks/php/src/Model/ApiAppResponseOwnerAccount.php +++ b/sdks/php/src/Model/ApiAppResponseOwnerAccount.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,12 +38,8 @@ * * @category Class * @description An object describing the app's owner - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class ApiAppResponseOwnerAccount implements ModelInterface, ArrayAccess, JsonSerializable { @@ -78,6 +74,23 @@ class ApiAppResponseOwnerAccount implements ModelInterface, ArrayAccess, JsonSer 'email_address' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'account_id' => false, + 'email_address' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -98,6 +111,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -173,38 +230,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['account_id'] = $data['account_id'] ?? null; - $this->container['email_address'] = $data['email_address'] ?? null; + $this->setIfExists('account_id', $data ?? [], null); + $this->setIfExists('email_address', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): ApiAppResponseOwnerAccount { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): ApiAppResponseOwnerAccount { - /** @var ApiAppResponseOwnerAccount $obj */ - $obj = ObjectSerializer::deserialize( + /** @var ApiAppResponseOwnerAccount */ + return ObjectSerializer::deserialize( $data, ApiAppResponseOwnerAccount::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -214,9 +289,7 @@ public static function init(array $data): ApiAppResponseOwnerAccount */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -249,6 +322,9 @@ public function getAccountId() */ public function setAccountId(?string $account_id) { + if (is_null($account_id)) { + throw new InvalidArgumentException('non-nullable account_id cannot be null'); + } $this->container['account_id'] = $account_id; return $this; @@ -273,6 +349,9 @@ public function getEmailAddress() */ public function setEmailAddress(?string $email_address) { + if (is_null($email_address)) { + throw new InvalidArgumentException('non-nullable email_address cannot be null'); + } $this->container['email_address'] = $email_address; return $this; @@ -281,12 +360,10 @@ public function setEmailAddress(?string $email_address) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -294,7 +371,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -307,13 +384,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -325,12 +400,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -339,8 +412,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/ApiAppResponseWhiteLabelingOptions.php b/sdks/php/src/Model/ApiAppResponseWhiteLabelingOptions.php index c2c659def..95f29f5f4 100644 --- a/sdks/php/src/Model/ApiAppResponseWhiteLabelingOptions.php +++ b/sdks/php/src/Model/ApiAppResponseWhiteLabelingOptions.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,12 +38,8 @@ * * @category Class * @description An object with options to customize the app's signer page - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class ApiAppResponseWhiteLabelingOptions implements ModelInterface, ArrayAccess, JsonSerializable { @@ -102,6 +98,35 @@ class ApiAppResponseWhiteLabelingOptions implements ModelInterface, ArrayAccess, 'text_color2' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'header_background_color' => false, + 'legal_version' => false, + 'link_color' => false, + 'page_background_color' => false, + 'primary_button_color' => false, + 'primary_button_color_hover' => false, + 'primary_button_text_color' => false, + 'primary_button_text_color_hover' => false, + 'secondary_button_color' => false, + 'secondary_button_color_hover' => false, + 'secondary_button_text_color' => false, + 'secondary_button_text_color_hover' => false, + 'text_color1' => false, + 'text_color2' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -122,6 +147,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -233,50 +302,68 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['header_background_color'] = $data['header_background_color'] ?? null; - $this->container['legal_version'] = $data['legal_version'] ?? null; - $this->container['link_color'] = $data['link_color'] ?? null; - $this->container['page_background_color'] = $data['page_background_color'] ?? null; - $this->container['primary_button_color'] = $data['primary_button_color'] ?? null; - $this->container['primary_button_color_hover'] = $data['primary_button_color_hover'] ?? null; - $this->container['primary_button_text_color'] = $data['primary_button_text_color'] ?? null; - $this->container['primary_button_text_color_hover'] = $data['primary_button_text_color_hover'] ?? null; - $this->container['secondary_button_color'] = $data['secondary_button_color'] ?? null; - $this->container['secondary_button_color_hover'] = $data['secondary_button_color_hover'] ?? null; - $this->container['secondary_button_text_color'] = $data['secondary_button_text_color'] ?? null; - $this->container['secondary_button_text_color_hover'] = $data['secondary_button_text_color_hover'] ?? null; - $this->container['text_color1'] = $data['text_color1'] ?? null; - $this->container['text_color2'] = $data['text_color2'] ?? null; - } - - /** @deprecated use ::init() */ + $this->setIfExists('header_background_color', $data ?? [], null); + $this->setIfExists('legal_version', $data ?? [], null); + $this->setIfExists('link_color', $data ?? [], null); + $this->setIfExists('page_background_color', $data ?? [], null); + $this->setIfExists('primary_button_color', $data ?? [], null); + $this->setIfExists('primary_button_color_hover', $data ?? [], null); + $this->setIfExists('primary_button_text_color', $data ?? [], null); + $this->setIfExists('primary_button_text_color_hover', $data ?? [], null); + $this->setIfExists('secondary_button_color', $data ?? [], null); + $this->setIfExists('secondary_button_color_hover', $data ?? [], null); + $this->setIfExists('secondary_button_text_color', $data ?? [], null); + $this->setIfExists('secondary_button_text_color_hover', $data ?? [], null); + $this->setIfExists('text_color1', $data ?? [], null); + $this->setIfExists('text_color2', $data ?? [], null); + } + + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): ApiAppResponseWhiteLabelingOptions { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): ApiAppResponseWhiteLabelingOptions { - /** @var ApiAppResponseWhiteLabelingOptions $obj */ - $obj = ObjectSerializer::deserialize( + /** @var ApiAppResponseWhiteLabelingOptions */ + return ObjectSerializer::deserialize( $data, ApiAppResponseWhiteLabelingOptions::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -286,9 +373,7 @@ public static function init(array $data): ApiAppResponseWhiteLabelingOptions */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -321,6 +406,9 @@ public function getHeaderBackgroundColor() */ public function setHeaderBackgroundColor(?string $header_background_color) { + if (is_null($header_background_color)) { + throw new InvalidArgumentException('non-nullable header_background_color cannot be null'); + } $this->container['header_background_color'] = $header_background_color; return $this; @@ -345,6 +433,9 @@ public function getLegalVersion() */ public function setLegalVersion(?string $legal_version) { + if (is_null($legal_version)) { + throw new InvalidArgumentException('non-nullable legal_version cannot be null'); + } $this->container['legal_version'] = $legal_version; return $this; @@ -369,6 +460,9 @@ public function getLinkColor() */ public function setLinkColor(?string $link_color) { + if (is_null($link_color)) { + throw new InvalidArgumentException('non-nullable link_color cannot be null'); + } $this->container['link_color'] = $link_color; return $this; @@ -393,6 +487,9 @@ public function getPageBackgroundColor() */ public function setPageBackgroundColor(?string $page_background_color) { + if (is_null($page_background_color)) { + throw new InvalidArgumentException('non-nullable page_background_color cannot be null'); + } $this->container['page_background_color'] = $page_background_color; return $this; @@ -417,6 +514,9 @@ public function getPrimaryButtonColor() */ public function setPrimaryButtonColor(?string $primary_button_color) { + if (is_null($primary_button_color)) { + throw new InvalidArgumentException('non-nullable primary_button_color cannot be null'); + } $this->container['primary_button_color'] = $primary_button_color; return $this; @@ -441,6 +541,9 @@ public function getPrimaryButtonColorHover() */ public function setPrimaryButtonColorHover(?string $primary_button_color_hover) { + if (is_null($primary_button_color_hover)) { + throw new InvalidArgumentException('non-nullable primary_button_color_hover cannot be null'); + } $this->container['primary_button_color_hover'] = $primary_button_color_hover; return $this; @@ -465,6 +568,9 @@ public function getPrimaryButtonTextColor() */ public function setPrimaryButtonTextColor(?string $primary_button_text_color) { + if (is_null($primary_button_text_color)) { + throw new InvalidArgumentException('non-nullable primary_button_text_color cannot be null'); + } $this->container['primary_button_text_color'] = $primary_button_text_color; return $this; @@ -489,6 +595,9 @@ public function getPrimaryButtonTextColorHover() */ public function setPrimaryButtonTextColorHover(?string $primary_button_text_color_hover) { + if (is_null($primary_button_text_color_hover)) { + throw new InvalidArgumentException('non-nullable primary_button_text_color_hover cannot be null'); + } $this->container['primary_button_text_color_hover'] = $primary_button_text_color_hover; return $this; @@ -513,6 +622,9 @@ public function getSecondaryButtonColor() */ public function setSecondaryButtonColor(?string $secondary_button_color) { + if (is_null($secondary_button_color)) { + throw new InvalidArgumentException('non-nullable secondary_button_color cannot be null'); + } $this->container['secondary_button_color'] = $secondary_button_color; return $this; @@ -537,6 +649,9 @@ public function getSecondaryButtonColorHover() */ public function setSecondaryButtonColorHover(?string $secondary_button_color_hover) { + if (is_null($secondary_button_color_hover)) { + throw new InvalidArgumentException('non-nullable secondary_button_color_hover cannot be null'); + } $this->container['secondary_button_color_hover'] = $secondary_button_color_hover; return $this; @@ -561,6 +676,9 @@ public function getSecondaryButtonTextColor() */ public function setSecondaryButtonTextColor(?string $secondary_button_text_color) { + if (is_null($secondary_button_text_color)) { + throw new InvalidArgumentException('non-nullable secondary_button_text_color cannot be null'); + } $this->container['secondary_button_text_color'] = $secondary_button_text_color; return $this; @@ -585,6 +703,9 @@ public function getSecondaryButtonTextColorHover() */ public function setSecondaryButtonTextColorHover(?string $secondary_button_text_color_hover) { + if (is_null($secondary_button_text_color_hover)) { + throw new InvalidArgumentException('non-nullable secondary_button_text_color_hover cannot be null'); + } $this->container['secondary_button_text_color_hover'] = $secondary_button_text_color_hover; return $this; @@ -609,6 +730,9 @@ public function getTextColor1() */ public function setTextColor1(?string $text_color1) { + if (is_null($text_color1)) { + throw new InvalidArgumentException('non-nullable text_color1 cannot be null'); + } $this->container['text_color1'] = $text_color1; return $this; @@ -633,6 +757,9 @@ public function getTextColor2() */ public function setTextColor2(?string $text_color2) { + if (is_null($text_color2)) { + throw new InvalidArgumentException('non-nullable text_color2 cannot be null'); + } $this->container['text_color2'] = $text_color2; return $this; @@ -641,12 +768,10 @@ public function setTextColor2(?string $text_color2) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -654,7 +779,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -667,13 +792,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -685,12 +808,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -699,8 +820,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/ApiAppUpdateRequest.php b/sdks/php/src/Model/ApiAppUpdateRequest.php index ddf4dcead..456d143c2 100644 --- a/sdks/php/src/Model/ApiAppUpdateRequest.php +++ b/sdks/php/src/Model/ApiAppUpdateRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -39,11 +38,8 @@ * ApiAppUpdateRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class ApiAppUpdateRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -88,6 +84,28 @@ class ApiAppUpdateRequest implements ModelInterface, ArrayAccess, JsonSerializab 'white_labeling_options' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'callback_url' => false, + 'custom_logo_file' => false, + 'domains' => false, + 'name' => false, + 'oauth' => false, + 'options' => false, + 'white_labeling_options' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -108,6 +126,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -198,43 +260,61 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['callback_url'] = $data['callback_url'] ?? null; - $this->container['custom_logo_file'] = $data['custom_logo_file'] ?? null; - $this->container['domains'] = $data['domains'] ?? null; - $this->container['name'] = $data['name'] ?? null; - $this->container['oauth'] = $data['oauth'] ?? null; - $this->container['options'] = $data['options'] ?? null; - $this->container['white_labeling_options'] = $data['white_labeling_options'] ?? null; + $this->setIfExists('callback_url', $data ?? [], null); + $this->setIfExists('custom_logo_file', $data ?? [], null); + $this->setIfExists('domains', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('oauth', $data ?? [], null); + $this->setIfExists('options', $data ?? [], null); + $this->setIfExists('white_labeling_options', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): ApiAppUpdateRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): ApiAppUpdateRequest { - /** @var ApiAppUpdateRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var ApiAppUpdateRequest */ + return ObjectSerializer::deserialize( $data, ApiAppUpdateRequest::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -283,6 +363,9 @@ public function getCallbackUrl() */ public function setCallbackUrl(?string $callback_url) { + if (is_null($callback_url)) { + throw new InvalidArgumentException('non-nullable callback_url cannot be null'); + } $this->container['callback_url'] = $callback_url; return $this; @@ -307,6 +390,9 @@ public function getCustomLogoFile() */ public function setCustomLogoFile(?SplFileObject $custom_logo_file) { + if (is_null($custom_logo_file)) { + throw new InvalidArgumentException('non-nullable custom_logo_file cannot be null'); + } $this->container['custom_logo_file'] = $custom_logo_file; return $this; @@ -331,7 +417,11 @@ public function getDomains() */ public function setDomains(?array $domains) { - if (!is_null($domains) && (count($domains) > 2)) { + if (is_null($domains)) { + throw new InvalidArgumentException('non-nullable domains cannot be null'); + } + + if (count($domains) > 2) { throw new InvalidArgumentException('invalid value for $domains when calling ApiAppUpdateRequest., number of items must be less than or equal to 2.'); } $this->container['domains'] = $domains; @@ -358,6 +448,9 @@ public function getName() */ public function setName(?string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -382,6 +475,9 @@ public function getOauth() */ public function setOauth(?SubOAuth $oauth) { + if (is_null($oauth)) { + throw new InvalidArgumentException('non-nullable oauth cannot be null'); + } $this->container['oauth'] = $oauth; return $this; @@ -406,6 +502,9 @@ public function getOptions() */ public function setOptions(?SubOptions $options) { + if (is_null($options)) { + throw new InvalidArgumentException('non-nullable options cannot be null'); + } $this->container['options'] = $options; return $this; @@ -430,6 +529,9 @@ public function getWhiteLabelingOptions() */ public function setWhiteLabelingOptions(?SubWhiteLabelingOptions $white_labeling_options) { + if (is_null($white_labeling_options)) { + throw new InvalidArgumentException('non-nullable white_labeling_options cannot be null'); + } $this->container['white_labeling_options'] = $white_labeling_options; return $this; @@ -438,12 +540,10 @@ public function setWhiteLabelingOptions(?SubWhiteLabelingOptions $white_labeling /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -451,7 +551,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -464,13 +564,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -482,12 +580,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -496,8 +592,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/BulkSendJobGetResponse.php b/sdks/php/src/Model/BulkSendJobGetResponse.php index 455e15b74..300bd887d 100644 --- a/sdks/php/src/Model/BulkSendJobGetResponse.php +++ b/sdks/php/src/Model/BulkSendJobGetResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * BulkSendJobGetResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class BulkSendJobGetResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -81,6 +77,25 @@ class BulkSendJobGetResponse implements ModelInterface, ArrayAccess, JsonSeriali 'warnings' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'bulk_send_job' => false, + 'list_info' => false, + 'signature_requests' => false, + 'warnings' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -101,6 +116,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -182,40 +241,58 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['bulk_send_job'] = $data['bulk_send_job'] ?? null; - $this->container['list_info'] = $data['list_info'] ?? null; - $this->container['signature_requests'] = $data['signature_requests'] ?? null; - $this->container['warnings'] = $data['warnings'] ?? null; + $this->setIfExists('bulk_send_job', $data ?? [], null); + $this->setIfExists('list_info', $data ?? [], null); + $this->setIfExists('signature_requests', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): BulkSendJobGetResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): BulkSendJobGetResponse { - /** @var BulkSendJobGetResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var BulkSendJobGetResponse */ + return ObjectSerializer::deserialize( $data, BulkSendJobGetResponse::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -225,9 +302,7 @@ public static function init(array $data): BulkSendJobGetResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -260,6 +335,9 @@ public function getBulkSendJob() */ public function setBulkSendJob(?BulkSendJobResponse $bulk_send_job) { + if (is_null($bulk_send_job)) { + throw new InvalidArgumentException('non-nullable bulk_send_job cannot be null'); + } $this->container['bulk_send_job'] = $bulk_send_job; return $this; @@ -284,6 +362,9 @@ public function getListInfo() */ public function setListInfo(?ListInfoResponse $list_info) { + if (is_null($list_info)) { + throw new InvalidArgumentException('non-nullable list_info cannot be null'); + } $this->container['list_info'] = $list_info; return $this; @@ -308,6 +389,9 @@ public function getSignatureRequests() */ public function setSignatureRequests(?array $signature_requests) { + if (is_null($signature_requests)) { + throw new InvalidArgumentException('non-nullable signature_requests cannot be null'); + } $this->container['signature_requests'] = $signature_requests; return $this; @@ -332,6 +416,9 @@ public function getWarnings() */ public function setWarnings(?array $warnings) { + if (is_null($warnings)) { + throw new InvalidArgumentException('non-nullable warnings cannot be null'); + } $this->container['warnings'] = $warnings; return $this; @@ -340,12 +427,10 @@ public function setWarnings(?array $warnings) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -353,7 +438,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -366,13 +451,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -384,12 +467,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -398,8 +479,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/BulkSendJobGetResponseSignatureRequests.php b/sdks/php/src/Model/BulkSendJobGetResponseSignatureRequests.php index a3cf4a0d1..3d30a8984 100644 --- a/sdks/php/src/Model/BulkSendJobGetResponseSignatureRequests.php +++ b/sdks/php/src/Model/BulkSendJobGetResponseSignatureRequests.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * BulkSendJobGetResponseSignatureRequests Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class BulkSendJobGetResponseSignatureRequests implements ModelInterface, ArrayAccess, JsonSerializable { @@ -123,6 +119,46 @@ class BulkSendJobGetResponseSignatureRequests implements ModelInterface, ArrayAc 'bulk_send_job_id' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'test_mode' => true, + 'signature_request_id' => false, + 'requester_email_address' => false, + 'title' => false, + 'original_title' => false, + 'subject' => true, + 'message' => true, + 'metadata' => false, + 'created_at' => false, + 'expires_at' => false, + 'is_complete' => false, + 'is_declined' => false, + 'has_error' => false, + 'files_url' => false, + 'signing_url' => true, + 'details_url' => false, + 'cc_email_addresses' => false, + 'signing_redirect_url' => true, + 'final_copy_uri' => true, + 'template_ids' => true, + 'custom_fields' => true, + 'attachments' => true, + 'response_data' => true, + 'signatures' => false, + 'bulk_send_job_id' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -143,6 +179,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -287,61 +367,79 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['test_mode'] = $data['test_mode'] ?? false; - $this->container['signature_request_id'] = $data['signature_request_id'] ?? null; - $this->container['requester_email_address'] = $data['requester_email_address'] ?? null; - $this->container['title'] = $data['title'] ?? null; - $this->container['original_title'] = $data['original_title'] ?? null; - $this->container['subject'] = $data['subject'] ?? null; - $this->container['message'] = $data['message'] ?? null; - $this->container['metadata'] = $data['metadata'] ?? null; - $this->container['created_at'] = $data['created_at'] ?? null; - $this->container['expires_at'] = $data['expires_at'] ?? null; - $this->container['is_complete'] = $data['is_complete'] ?? null; - $this->container['is_declined'] = $data['is_declined'] ?? null; - $this->container['has_error'] = $data['has_error'] ?? null; - $this->container['files_url'] = $data['files_url'] ?? null; - $this->container['signing_url'] = $data['signing_url'] ?? null; - $this->container['details_url'] = $data['details_url'] ?? null; - $this->container['cc_email_addresses'] = $data['cc_email_addresses'] ?? null; - $this->container['signing_redirect_url'] = $data['signing_redirect_url'] ?? null; - $this->container['final_copy_uri'] = $data['final_copy_uri'] ?? null; - $this->container['template_ids'] = $data['template_ids'] ?? null; - $this->container['custom_fields'] = $data['custom_fields'] ?? null; - $this->container['attachments'] = $data['attachments'] ?? null; - $this->container['response_data'] = $data['response_data'] ?? null; - $this->container['signatures'] = $data['signatures'] ?? null; - $this->container['bulk_send_job_id'] = $data['bulk_send_job_id'] ?? null; - } - - /** @deprecated use ::init() */ + $this->setIfExists('test_mode', $data ?? [], false); + $this->setIfExists('signature_request_id', $data ?? [], null); + $this->setIfExists('requester_email_address', $data ?? [], null); + $this->setIfExists('title', $data ?? [], null); + $this->setIfExists('original_title', $data ?? [], null); + $this->setIfExists('subject', $data ?? [], null); + $this->setIfExists('message', $data ?? [], null); + $this->setIfExists('metadata', $data ?? [], null); + $this->setIfExists('created_at', $data ?? [], null); + $this->setIfExists('expires_at', $data ?? [], null); + $this->setIfExists('is_complete', $data ?? [], null); + $this->setIfExists('is_declined', $data ?? [], null); + $this->setIfExists('has_error', $data ?? [], null); + $this->setIfExists('files_url', $data ?? [], null); + $this->setIfExists('signing_url', $data ?? [], null); + $this->setIfExists('details_url', $data ?? [], null); + $this->setIfExists('cc_email_addresses', $data ?? [], null); + $this->setIfExists('signing_redirect_url', $data ?? [], null); + $this->setIfExists('final_copy_uri', $data ?? [], null); + $this->setIfExists('template_ids', $data ?? [], null); + $this->setIfExists('custom_fields', $data ?? [], null); + $this->setIfExists('attachments', $data ?? [], null); + $this->setIfExists('response_data', $data ?? [], null); + $this->setIfExists('signatures', $data ?? [], null); + $this->setIfExists('bulk_send_job_id', $data ?? [], null); + } + + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): BulkSendJobGetResponseSignatureRequests { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): BulkSendJobGetResponseSignatureRequests { - /** @var BulkSendJobGetResponseSignatureRequests $obj */ - $obj = ObjectSerializer::deserialize( + /** @var BulkSendJobGetResponseSignatureRequests */ + return ObjectSerializer::deserialize( $data, BulkSendJobGetResponseSignatureRequests::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -351,9 +449,7 @@ public static function init(array $data): BulkSendJobGetResponseSignatureRequest */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -386,6 +482,16 @@ public function getTestMode() */ public function setTestMode(?bool $test_mode) { + if (is_null($test_mode)) { + array_push($this->openAPINullablesSetToNull, 'test_mode'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('test_mode', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['test_mode'] = $test_mode; return $this; @@ -410,6 +516,9 @@ public function getSignatureRequestId() */ public function setSignatureRequestId(?string $signature_request_id) { + if (is_null($signature_request_id)) { + throw new InvalidArgumentException('non-nullable signature_request_id cannot be null'); + } $this->container['signature_request_id'] = $signature_request_id; return $this; @@ -434,6 +543,9 @@ public function getRequesterEmailAddress() */ public function setRequesterEmailAddress(?string $requester_email_address) { + if (is_null($requester_email_address)) { + throw new InvalidArgumentException('non-nullable requester_email_address cannot be null'); + } $this->container['requester_email_address'] = $requester_email_address; return $this; @@ -458,6 +570,9 @@ public function getTitle() */ public function setTitle(?string $title) { + if (is_null($title)) { + throw new InvalidArgumentException('non-nullable title cannot be null'); + } $this->container['title'] = $title; return $this; @@ -482,6 +597,9 @@ public function getOriginalTitle() */ public function setOriginalTitle(?string $original_title) { + if (is_null($original_title)) { + throw new InvalidArgumentException('non-nullable original_title cannot be null'); + } $this->container['original_title'] = $original_title; return $this; @@ -506,6 +624,16 @@ public function getSubject() */ public function setSubject(?string $subject) { + if (is_null($subject)) { + array_push($this->openAPINullablesSetToNull, 'subject'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('subject', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['subject'] = $subject; return $this; @@ -530,6 +658,16 @@ public function getMessage() */ public function setMessage(?string $message) { + if (is_null($message)) { + array_push($this->openAPINullablesSetToNull, 'message'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('message', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['message'] = $message; return $this; @@ -554,6 +692,9 @@ public function getMetadata() */ public function setMetadata(?array $metadata) { + if (is_null($metadata)) { + throw new InvalidArgumentException('non-nullable metadata cannot be null'); + } $this->container['metadata'] = $metadata; return $this; @@ -578,6 +719,9 @@ public function getCreatedAt() */ public function setCreatedAt(?int $created_at) { + if (is_null($created_at)) { + throw new InvalidArgumentException('non-nullable created_at cannot be null'); + } $this->container['created_at'] = $created_at; return $this; @@ -602,6 +746,9 @@ public function getExpiresAt() */ public function setExpiresAt(?int $expires_at) { + if (is_null($expires_at)) { + throw new InvalidArgumentException('non-nullable expires_at cannot be null'); + } $this->container['expires_at'] = $expires_at; return $this; @@ -626,6 +773,9 @@ public function getIsComplete() */ public function setIsComplete(?bool $is_complete) { + if (is_null($is_complete)) { + throw new InvalidArgumentException('non-nullable is_complete cannot be null'); + } $this->container['is_complete'] = $is_complete; return $this; @@ -650,6 +800,9 @@ public function getIsDeclined() */ public function setIsDeclined(?bool $is_declined) { + if (is_null($is_declined)) { + throw new InvalidArgumentException('non-nullable is_declined cannot be null'); + } $this->container['is_declined'] = $is_declined; return $this; @@ -674,6 +827,9 @@ public function getHasError() */ public function setHasError(?bool $has_error) { + if (is_null($has_error)) { + throw new InvalidArgumentException('non-nullable has_error cannot be null'); + } $this->container['has_error'] = $has_error; return $this; @@ -698,6 +854,9 @@ public function getFilesUrl() */ public function setFilesUrl(?string $files_url) { + if (is_null($files_url)) { + throw new InvalidArgumentException('non-nullable files_url cannot be null'); + } $this->container['files_url'] = $files_url; return $this; @@ -722,6 +881,16 @@ public function getSigningUrl() */ public function setSigningUrl(?string $signing_url) { + if (is_null($signing_url)) { + array_push($this->openAPINullablesSetToNull, 'signing_url'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('signing_url', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['signing_url'] = $signing_url; return $this; @@ -746,6 +915,9 @@ public function getDetailsUrl() */ public function setDetailsUrl(?string $details_url) { + if (is_null($details_url)) { + throw new InvalidArgumentException('non-nullable details_url cannot be null'); + } $this->container['details_url'] = $details_url; return $this; @@ -770,6 +942,9 @@ public function getCcEmailAddresses() */ public function setCcEmailAddresses(?array $cc_email_addresses) { + if (is_null($cc_email_addresses)) { + throw new InvalidArgumentException('non-nullable cc_email_addresses cannot be null'); + } $this->container['cc_email_addresses'] = $cc_email_addresses; return $this; @@ -794,6 +969,16 @@ public function getSigningRedirectUrl() */ public function setSigningRedirectUrl(?string $signing_redirect_url) { + if (is_null($signing_redirect_url)) { + array_push($this->openAPINullablesSetToNull, 'signing_redirect_url'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('signing_redirect_url', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['signing_redirect_url'] = $signing_redirect_url; return $this; @@ -818,6 +1003,16 @@ public function getFinalCopyUri() */ public function setFinalCopyUri(?string $final_copy_uri) { + if (is_null($final_copy_uri)) { + array_push($this->openAPINullablesSetToNull, 'final_copy_uri'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('final_copy_uri', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['final_copy_uri'] = $final_copy_uri; return $this; @@ -842,6 +1037,16 @@ public function getTemplateIds() */ public function setTemplateIds(?array $template_ids) { + if (is_null($template_ids)) { + array_push($this->openAPINullablesSetToNull, 'template_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('template_ids', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['template_ids'] = $template_ids; return $this; @@ -866,6 +1071,16 @@ public function getCustomFields() */ public function setCustomFields(?array $custom_fields) { + if (is_null($custom_fields)) { + array_push($this->openAPINullablesSetToNull, 'custom_fields'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('custom_fields', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['custom_fields'] = $custom_fields; return $this; @@ -890,6 +1105,16 @@ public function getAttachments() */ public function setAttachments(?array $attachments) { + if (is_null($attachments)) { + array_push($this->openAPINullablesSetToNull, 'attachments'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('attachments', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['attachments'] = $attachments; return $this; @@ -914,6 +1139,16 @@ public function getResponseData() */ public function setResponseData(?array $response_data) { + if (is_null($response_data)) { + array_push($this->openAPINullablesSetToNull, 'response_data'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('response_data', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['response_data'] = $response_data; return $this; @@ -938,6 +1173,9 @@ public function getSignatures() */ public function setSignatures(?array $signatures) { + if (is_null($signatures)) { + throw new InvalidArgumentException('non-nullable signatures cannot be null'); + } $this->container['signatures'] = $signatures; return $this; @@ -962,6 +1200,9 @@ public function getBulkSendJobId() */ public function setBulkSendJobId(?string $bulk_send_job_id) { + if (is_null($bulk_send_job_id)) { + throw new InvalidArgumentException('non-nullable bulk_send_job_id cannot be null'); + } $this->container['bulk_send_job_id'] = $bulk_send_job_id; return $this; @@ -970,12 +1211,10 @@ public function setBulkSendJobId(?string $bulk_send_job_id) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -983,7 +1222,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -996,13 +1235,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -1014,12 +1251,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -1028,8 +1263,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/BulkSendJobListResponse.php b/sdks/php/src/Model/BulkSendJobListResponse.php index 741473fe8..453f08e29 100644 --- a/sdks/php/src/Model/BulkSendJobListResponse.php +++ b/sdks/php/src/Model/BulkSendJobListResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * BulkSendJobListResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class BulkSendJobListResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -79,6 +75,24 @@ class BulkSendJobListResponse implements ModelInterface, ArrayAccess, JsonSerial 'warnings' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'bulk_send_jobs' => false, + 'list_info' => false, + 'warnings' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -99,6 +113,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -177,39 +235,57 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['bulk_send_jobs'] = $data['bulk_send_jobs'] ?? null; - $this->container['list_info'] = $data['list_info'] ?? null; - $this->container['warnings'] = $data['warnings'] ?? null; + $this->setIfExists('bulk_send_jobs', $data ?? [], null); + $this->setIfExists('list_info', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): BulkSendJobListResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): BulkSendJobListResponse { - /** @var BulkSendJobListResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var BulkSendJobListResponse */ + return ObjectSerializer::deserialize( $data, BulkSendJobListResponse::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -219,9 +295,7 @@ public static function init(array $data): BulkSendJobListResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -254,6 +328,9 @@ public function getBulkSendJobs() */ public function setBulkSendJobs(?array $bulk_send_jobs) { + if (is_null($bulk_send_jobs)) { + throw new InvalidArgumentException('non-nullable bulk_send_jobs cannot be null'); + } $this->container['bulk_send_jobs'] = $bulk_send_jobs; return $this; @@ -278,6 +355,9 @@ public function getListInfo() */ public function setListInfo(?ListInfoResponse $list_info) { + if (is_null($list_info)) { + throw new InvalidArgumentException('non-nullable list_info cannot be null'); + } $this->container['list_info'] = $list_info; return $this; @@ -302,6 +382,9 @@ public function getWarnings() */ public function setWarnings(?array $warnings) { + if (is_null($warnings)) { + throw new InvalidArgumentException('non-nullable warnings cannot be null'); + } $this->container['warnings'] = $warnings; return $this; @@ -310,12 +393,10 @@ public function setWarnings(?array $warnings) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -323,7 +404,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -336,13 +417,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -354,12 +433,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -368,8 +445,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/BulkSendJobResponse.php b/sdks/php/src/Model/BulkSendJobResponse.php index 47c0fb6b2..fcd66e120 100644 --- a/sdks/php/src/Model/BulkSendJobResponse.php +++ b/sdks/php/src/Model/BulkSendJobResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,12 +38,8 @@ * * @category Class * @description Contains information about the BulkSendJob such as when it was created and how many signature requests are queued. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class BulkSendJobResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -82,6 +78,25 @@ class BulkSendJobResponse implements ModelInterface, ArrayAccess, JsonSerializab 'created_at' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'bulk_send_job_id' => true, + 'total' => false, + 'is_creator' => false, + 'created_at' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -102,6 +117,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -183,40 +242,58 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['bulk_send_job_id'] = $data['bulk_send_job_id'] ?? null; - $this->container['total'] = $data['total'] ?? null; - $this->container['is_creator'] = $data['is_creator'] ?? null; - $this->container['created_at'] = $data['created_at'] ?? null; + $this->setIfExists('bulk_send_job_id', $data ?? [], null); + $this->setIfExists('total', $data ?? [], null); + $this->setIfExists('is_creator', $data ?? [], null); + $this->setIfExists('created_at', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): BulkSendJobResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): BulkSendJobResponse { - /** @var BulkSendJobResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var BulkSendJobResponse */ + return ObjectSerializer::deserialize( $data, BulkSendJobResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -226,9 +303,7 @@ public static function init(array $data): BulkSendJobResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -261,6 +336,16 @@ public function getBulkSendJobId() */ public function setBulkSendJobId(?string $bulk_send_job_id) { + if (is_null($bulk_send_job_id)) { + array_push($this->openAPINullablesSetToNull, 'bulk_send_job_id'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('bulk_send_job_id', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['bulk_send_job_id'] = $bulk_send_job_id; return $this; @@ -285,6 +370,9 @@ public function getTotal() */ public function setTotal(?int $total) { + if (is_null($total)) { + throw new InvalidArgumentException('non-nullable total cannot be null'); + } $this->container['total'] = $total; return $this; @@ -309,6 +397,9 @@ public function getIsCreator() */ public function setIsCreator(?bool $is_creator) { + if (is_null($is_creator)) { + throw new InvalidArgumentException('non-nullable is_creator cannot be null'); + } $this->container['is_creator'] = $is_creator; return $this; @@ -333,6 +424,9 @@ public function getCreatedAt() */ public function setCreatedAt(?int $created_at) { + if (is_null($created_at)) { + throw new InvalidArgumentException('non-nullable created_at cannot be null'); + } $this->container['created_at'] = $created_at; return $this; @@ -341,12 +435,10 @@ public function setCreatedAt(?int $created_at) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -354,7 +446,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -367,13 +459,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -385,12 +475,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -399,8 +487,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/BulkSendJobSendResponse.php b/sdks/php/src/Model/BulkSendJobSendResponse.php index 0f4ef7b63..e8642fadf 100644 --- a/sdks/php/src/Model/BulkSendJobSendResponse.php +++ b/sdks/php/src/Model/BulkSendJobSendResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * BulkSendJobSendResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class BulkSendJobSendResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -77,6 +73,23 @@ class BulkSendJobSendResponse implements ModelInterface, ArrayAccess, JsonSerial 'warnings' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'bulk_send_job' => false, + 'warnings' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -97,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -172,38 +229,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['bulk_send_job'] = $data['bulk_send_job'] ?? null; - $this->container['warnings'] = $data['warnings'] ?? null; + $this->setIfExists('bulk_send_job', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): BulkSendJobSendResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): BulkSendJobSendResponse { - /** @var BulkSendJobSendResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var BulkSendJobSendResponse */ + return ObjectSerializer::deserialize( $data, BulkSendJobSendResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -213,9 +288,7 @@ public static function init(array $data): BulkSendJobSendResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -248,6 +321,9 @@ public function getBulkSendJob() */ public function setBulkSendJob(?BulkSendJobResponse $bulk_send_job) { + if (is_null($bulk_send_job)) { + throw new InvalidArgumentException('non-nullable bulk_send_job cannot be null'); + } $this->container['bulk_send_job'] = $bulk_send_job; return $this; @@ -272,6 +348,9 @@ public function getWarnings() */ public function setWarnings(?array $warnings) { + if (is_null($warnings)) { + throw new InvalidArgumentException('non-nullable warnings cannot be null'); + } $this->container['warnings'] = $warnings; return $this; @@ -280,12 +359,10 @@ public function setWarnings(?array $warnings) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -293,7 +370,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -306,13 +383,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -324,12 +399,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -338,8 +411,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/EmbeddedEditUrlRequest.php b/sdks/php/src/Model/EmbeddedEditUrlRequest.php index 7fe2004c0..b4992a4c8 100644 --- a/sdks/php/src/Model/EmbeddedEditUrlRequest.php +++ b/sdks/php/src/Model/EmbeddedEditUrlRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * EmbeddedEditUrlRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class EmbeddedEditUrlRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -92,6 +89,31 @@ class EmbeddedEditUrlRequest implements ModelInterface, ArrayAccess, JsonSeriali 'test_mode' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'allow_edit_ccs' => false, + 'cc_roles' => false, + 'editor_options' => false, + 'force_signer_roles' => false, + 'force_subject_message' => false, + 'merge_fields' => false, + 'preview_only' => false, + 'show_preview' => false, + 'show_progress_stepper' => false, + 'test_mode' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -112,6 +134,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -211,46 +277,64 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['allow_edit_ccs'] = $data['allow_edit_ccs'] ?? false; - $this->container['cc_roles'] = $data['cc_roles'] ?? null; - $this->container['editor_options'] = $data['editor_options'] ?? null; - $this->container['force_signer_roles'] = $data['force_signer_roles'] ?? false; - $this->container['force_subject_message'] = $data['force_subject_message'] ?? false; - $this->container['merge_fields'] = $data['merge_fields'] ?? null; - $this->container['preview_only'] = $data['preview_only'] ?? false; - $this->container['show_preview'] = $data['show_preview'] ?? false; - $this->container['show_progress_stepper'] = $data['show_progress_stepper'] ?? true; - $this->container['test_mode'] = $data['test_mode'] ?? false; + $this->setIfExists('allow_edit_ccs', $data ?? [], false); + $this->setIfExists('cc_roles', $data ?? [], null); + $this->setIfExists('editor_options', $data ?? [], null); + $this->setIfExists('force_signer_roles', $data ?? [], false); + $this->setIfExists('force_subject_message', $data ?? [], false); + $this->setIfExists('merge_fields', $data ?? [], null); + $this->setIfExists('preview_only', $data ?? [], false); + $this->setIfExists('show_preview', $data ?? [], false); + $this->setIfExists('show_progress_stepper', $data ?? [], true); + $this->setIfExists('test_mode', $data ?? [], false); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): EmbeddedEditUrlRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): EmbeddedEditUrlRequest { - /** @var EmbeddedEditUrlRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var EmbeddedEditUrlRequest */ + return ObjectSerializer::deserialize( $data, EmbeddedEditUrlRequest::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -260,9 +344,7 @@ public static function init(array $data): EmbeddedEditUrlRequest */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -295,6 +377,9 @@ public function getAllowEditCcs() */ public function setAllowEditCcs(?bool $allow_edit_ccs) { + if (is_null($allow_edit_ccs)) { + throw new InvalidArgumentException('non-nullable allow_edit_ccs cannot be null'); + } $this->container['allow_edit_ccs'] = $allow_edit_ccs; return $this; @@ -319,6 +404,9 @@ public function getCcRoles() */ public function setCcRoles(?array $cc_roles) { + if (is_null($cc_roles)) { + throw new InvalidArgumentException('non-nullable cc_roles cannot be null'); + } $this->container['cc_roles'] = $cc_roles; return $this; @@ -343,6 +431,9 @@ public function getEditorOptions() */ public function setEditorOptions(?SubEditorOptions $editor_options) { + if (is_null($editor_options)) { + throw new InvalidArgumentException('non-nullable editor_options cannot be null'); + } $this->container['editor_options'] = $editor_options; return $this; @@ -367,6 +458,9 @@ public function getForceSignerRoles() */ public function setForceSignerRoles(?bool $force_signer_roles) { + if (is_null($force_signer_roles)) { + throw new InvalidArgumentException('non-nullable force_signer_roles cannot be null'); + } $this->container['force_signer_roles'] = $force_signer_roles; return $this; @@ -391,6 +485,9 @@ public function getForceSubjectMessage() */ public function setForceSubjectMessage(?bool $force_subject_message) { + if (is_null($force_subject_message)) { + throw new InvalidArgumentException('non-nullable force_subject_message cannot be null'); + } $this->container['force_subject_message'] = $force_subject_message; return $this; @@ -415,6 +512,9 @@ public function getMergeFields() */ public function setMergeFields(?array $merge_fields) { + if (is_null($merge_fields)) { + throw new InvalidArgumentException('non-nullable merge_fields cannot be null'); + } $this->container['merge_fields'] = $merge_fields; return $this; @@ -439,6 +539,9 @@ public function getPreviewOnly() */ public function setPreviewOnly(?bool $preview_only) { + if (is_null($preview_only)) { + throw new InvalidArgumentException('non-nullable preview_only cannot be null'); + } $this->container['preview_only'] = $preview_only; return $this; @@ -463,6 +566,9 @@ public function getShowPreview() */ public function setShowPreview(?bool $show_preview) { + if (is_null($show_preview)) { + throw new InvalidArgumentException('non-nullable show_preview cannot be null'); + } $this->container['show_preview'] = $show_preview; return $this; @@ -487,6 +593,9 @@ public function getShowProgressStepper() */ public function setShowProgressStepper(?bool $show_progress_stepper) { + if (is_null($show_progress_stepper)) { + throw new InvalidArgumentException('non-nullable show_progress_stepper cannot be null'); + } $this->container['show_progress_stepper'] = $show_progress_stepper; return $this; @@ -511,6 +620,9 @@ public function getTestMode() */ public function setTestMode(?bool $test_mode) { + if (is_null($test_mode)) { + throw new InvalidArgumentException('non-nullable test_mode cannot be null'); + } $this->container['test_mode'] = $test_mode; return $this; @@ -519,12 +631,10 @@ public function setTestMode(?bool $test_mode) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -532,7 +642,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -545,13 +655,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -563,12 +671,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -577,8 +683,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/EmbeddedEditUrlResponse.php b/sdks/php/src/Model/EmbeddedEditUrlResponse.php index 79535fda8..71a6fe19c 100644 --- a/sdks/php/src/Model/EmbeddedEditUrlResponse.php +++ b/sdks/php/src/Model/EmbeddedEditUrlResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * EmbeddedEditUrlResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class EmbeddedEditUrlResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -77,6 +73,23 @@ class EmbeddedEditUrlResponse implements ModelInterface, ArrayAccess, JsonSerial 'warnings' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'embedded' => false, + 'warnings' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -97,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -172,38 +229,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['embedded'] = $data['embedded'] ?? null; - $this->container['warnings'] = $data['warnings'] ?? null; + $this->setIfExists('embedded', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): EmbeddedEditUrlResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): EmbeddedEditUrlResponse { - /** @var EmbeddedEditUrlResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var EmbeddedEditUrlResponse */ + return ObjectSerializer::deserialize( $data, EmbeddedEditUrlResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -213,9 +288,7 @@ public static function init(array $data): EmbeddedEditUrlResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -248,6 +321,9 @@ public function getEmbedded() */ public function setEmbedded(?EmbeddedEditUrlResponseEmbedded $embedded) { + if (is_null($embedded)) { + throw new InvalidArgumentException('non-nullable embedded cannot be null'); + } $this->container['embedded'] = $embedded; return $this; @@ -272,6 +348,9 @@ public function getWarnings() */ public function setWarnings(?array $warnings) { + if (is_null($warnings)) { + throw new InvalidArgumentException('non-nullable warnings cannot be null'); + } $this->container['warnings'] = $warnings; return $this; @@ -280,12 +359,10 @@ public function setWarnings(?array $warnings) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -293,7 +370,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -306,13 +383,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -324,12 +399,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -338,8 +411,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/EmbeddedEditUrlResponseEmbedded.php b/sdks/php/src/Model/EmbeddedEditUrlResponseEmbedded.php index b568090ab..0ef35374f 100644 --- a/sdks/php/src/Model/EmbeddedEditUrlResponseEmbedded.php +++ b/sdks/php/src/Model/EmbeddedEditUrlResponseEmbedded.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,12 +38,8 @@ * * @category Class * @description An embedded template object. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class EmbeddedEditUrlResponseEmbedded implements ModelInterface, ArrayAccess, JsonSerializable { @@ -78,6 +74,23 @@ class EmbeddedEditUrlResponseEmbedded implements ModelInterface, ArrayAccess, Js 'expires_at' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'edit_url' => false, + 'expires_at' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -98,6 +111,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -173,38 +230,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['edit_url'] = $data['edit_url'] ?? null; - $this->container['expires_at'] = $data['expires_at'] ?? null; + $this->setIfExists('edit_url', $data ?? [], null); + $this->setIfExists('expires_at', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): EmbeddedEditUrlResponseEmbedded { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): EmbeddedEditUrlResponseEmbedded { - /** @var EmbeddedEditUrlResponseEmbedded $obj */ - $obj = ObjectSerializer::deserialize( + /** @var EmbeddedEditUrlResponseEmbedded */ + return ObjectSerializer::deserialize( $data, EmbeddedEditUrlResponseEmbedded::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -214,9 +289,7 @@ public static function init(array $data): EmbeddedEditUrlResponseEmbedded */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -249,6 +322,9 @@ public function getEditUrl() */ public function setEditUrl(?string $edit_url) { + if (is_null($edit_url)) { + throw new InvalidArgumentException('non-nullable edit_url cannot be null'); + } $this->container['edit_url'] = $edit_url; return $this; @@ -273,6 +349,9 @@ public function getExpiresAt() */ public function setExpiresAt(?int $expires_at) { + if (is_null($expires_at)) { + throw new InvalidArgumentException('non-nullable expires_at cannot be null'); + } $this->container['expires_at'] = $expires_at; return $this; @@ -281,12 +360,10 @@ public function setExpiresAt(?int $expires_at) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -294,7 +371,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -307,13 +384,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -325,12 +400,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -339,8 +412,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/EmbeddedSignUrlResponse.php b/sdks/php/src/Model/EmbeddedSignUrlResponse.php index 8cf8ebb71..75774541a 100644 --- a/sdks/php/src/Model/EmbeddedSignUrlResponse.php +++ b/sdks/php/src/Model/EmbeddedSignUrlResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * EmbeddedSignUrlResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class EmbeddedSignUrlResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -77,6 +73,23 @@ class EmbeddedSignUrlResponse implements ModelInterface, ArrayAccess, JsonSerial 'warnings' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'embedded' => false, + 'warnings' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -97,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -172,38 +229,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['embedded'] = $data['embedded'] ?? null; - $this->container['warnings'] = $data['warnings'] ?? null; + $this->setIfExists('embedded', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): EmbeddedSignUrlResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): EmbeddedSignUrlResponse { - /** @var EmbeddedSignUrlResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var EmbeddedSignUrlResponse */ + return ObjectSerializer::deserialize( $data, EmbeddedSignUrlResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -213,9 +288,7 @@ public static function init(array $data): EmbeddedSignUrlResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -248,6 +321,9 @@ public function getEmbedded() */ public function setEmbedded(?EmbeddedSignUrlResponseEmbedded $embedded) { + if (is_null($embedded)) { + throw new InvalidArgumentException('non-nullable embedded cannot be null'); + } $this->container['embedded'] = $embedded; return $this; @@ -272,6 +348,9 @@ public function getWarnings() */ public function setWarnings(?array $warnings) { + if (is_null($warnings)) { + throw new InvalidArgumentException('non-nullable warnings cannot be null'); + } $this->container['warnings'] = $warnings; return $this; @@ -280,12 +359,10 @@ public function setWarnings(?array $warnings) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -293,7 +370,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -306,13 +383,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -324,12 +399,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -338,8 +411,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/EmbeddedSignUrlResponseEmbedded.php b/sdks/php/src/Model/EmbeddedSignUrlResponseEmbedded.php index b33b67d36..f8b6619ba 100644 --- a/sdks/php/src/Model/EmbeddedSignUrlResponseEmbedded.php +++ b/sdks/php/src/Model/EmbeddedSignUrlResponseEmbedded.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,12 +38,8 @@ * * @category Class * @description An object that contains necessary information to set up embedded signing. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class EmbeddedSignUrlResponseEmbedded implements ModelInterface, ArrayAccess, JsonSerializable { @@ -78,6 +74,23 @@ class EmbeddedSignUrlResponseEmbedded implements ModelInterface, ArrayAccess, Js 'expires_at' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'sign_url' => false, + 'expires_at' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -98,6 +111,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -173,38 +230,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['sign_url'] = $data['sign_url'] ?? null; - $this->container['expires_at'] = $data['expires_at'] ?? null; + $this->setIfExists('sign_url', $data ?? [], null); + $this->setIfExists('expires_at', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): EmbeddedSignUrlResponseEmbedded { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): EmbeddedSignUrlResponseEmbedded { - /** @var EmbeddedSignUrlResponseEmbedded $obj */ - $obj = ObjectSerializer::deserialize( + /** @var EmbeddedSignUrlResponseEmbedded */ + return ObjectSerializer::deserialize( $data, EmbeddedSignUrlResponseEmbedded::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -214,9 +289,7 @@ public static function init(array $data): EmbeddedSignUrlResponseEmbedded */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -249,6 +322,9 @@ public function getSignUrl() */ public function setSignUrl(?string $sign_url) { + if (is_null($sign_url)) { + throw new InvalidArgumentException('non-nullable sign_url cannot be null'); + } $this->container['sign_url'] = $sign_url; return $this; @@ -273,6 +349,9 @@ public function getExpiresAt() */ public function setExpiresAt(?int $expires_at) { + if (is_null($expires_at)) { + throw new InvalidArgumentException('non-nullable expires_at cannot be null'); + } $this->container['expires_at'] = $expires_at; return $this; @@ -281,12 +360,10 @@ public function setExpiresAt(?int $expires_at) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -294,7 +371,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -307,13 +384,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -325,12 +400,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -339,8 +412,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/ErrorResponse.php b/sdks/php/src/Model/ErrorResponse.php index 4770b26d2..081ed78c0 100644 --- a/sdks/php/src/Model/ErrorResponse.php +++ b/sdks/php/src/Model/ErrorResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * ErrorResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class ErrorResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -74,6 +71,22 @@ class ErrorResponse implements ModelInterface, ArrayAccess, JsonSerializable 'error' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'error' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -94,6 +107,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -166,37 +223,55 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['error'] = $data['error'] ?? null; + $this->setIfExists('error', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): ErrorResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): ErrorResponse { - /** @var ErrorResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var ErrorResponse */ + return ObjectSerializer::deserialize( $data, ErrorResponse::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -211,7 +286,6 @@ public function listInvalidProperties() if ($this->container['error'] === null) { $invalidProperties[] = "'error' can't be null"; } - return $invalidProperties; } @@ -245,6 +319,9 @@ public function getError() */ public function setError(ErrorResponseError $error) { + if (is_null($error)) { + throw new InvalidArgumentException('non-nullable error cannot be null'); + } $this->container['error'] = $error; return $this; @@ -253,12 +330,10 @@ public function setError(ErrorResponseError $error) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -266,7 +341,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -279,13 +354,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -297,12 +370,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -311,8 +382,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/ErrorResponseError.php b/sdks/php/src/Model/ErrorResponseError.php index 30c5eb346..60981920d 100644 --- a/sdks/php/src/Model/ErrorResponseError.php +++ b/sdks/php/src/Model/ErrorResponseError.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,11 +38,8 @@ * * @category Class * @description Contains information about an error that occurred. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class ErrorResponseError implements ModelInterface, ArrayAccess, JsonSerializable { @@ -79,6 +76,24 @@ class ErrorResponseError implements ModelInterface, ArrayAccess, JsonSerializabl 'error_path' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'error_msg' => false, + 'error_name' => false, + 'error_path' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -99,6 +114,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -177,39 +236,57 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['error_msg'] = $data['error_msg'] ?? null; - $this->container['error_name'] = $data['error_name'] ?? null; - $this->container['error_path'] = $data['error_path'] ?? null; + $this->setIfExists('error_msg', $data ?? [], null); + $this->setIfExists('error_name', $data ?? [], null); + $this->setIfExists('error_path', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): ErrorResponseError { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): ErrorResponseError { - /** @var ErrorResponseError $obj */ - $obj = ObjectSerializer::deserialize( + /** @var ErrorResponseError */ + return ObjectSerializer::deserialize( $data, ErrorResponseError::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -227,7 +304,6 @@ public function listInvalidProperties() if ($this->container['error_name'] === null) { $invalidProperties[] = "'error_name' can't be null"; } - return $invalidProperties; } @@ -261,6 +337,9 @@ public function getErrorMsg() */ public function setErrorMsg(string $error_msg) { + if (is_null($error_msg)) { + throw new InvalidArgumentException('non-nullable error_msg cannot be null'); + } $this->container['error_msg'] = $error_msg; return $this; @@ -285,6 +364,9 @@ public function getErrorName() */ public function setErrorName(string $error_name) { + if (is_null($error_name)) { + throw new InvalidArgumentException('non-nullable error_name cannot be null'); + } $this->container['error_name'] = $error_name; return $this; @@ -309,6 +391,9 @@ public function getErrorPath() */ public function setErrorPath(?string $error_path) { + if (is_null($error_path)) { + throw new InvalidArgumentException('non-nullable error_path cannot be null'); + } $this->container['error_path'] = $error_path; return $this; @@ -317,12 +402,10 @@ public function setErrorPath(?string $error_path) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -330,7 +413,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -343,13 +426,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -361,12 +442,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -375,8 +454,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/EventCallbackRequest.php b/sdks/php/src/Model/EventCallbackRequest.php index 10819f45f..35c806b2d 100644 --- a/sdks/php/src/Model/EventCallbackRequest.php +++ b/sdks/php/src/Model/EventCallbackRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * EventCallbackRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class EventCallbackRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -80,6 +77,25 @@ class EventCallbackRequest implements ModelInterface, ArrayAccess, JsonSerializa 'template' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'event' => false, + 'account' => false, + 'signature_request' => false, + 'template' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -100,6 +116,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -181,40 +241,58 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['event'] = $data['event'] ?? null; - $this->container['account'] = $data['account'] ?? null; - $this->container['signature_request'] = $data['signature_request'] ?? null; - $this->container['template'] = $data['template'] ?? null; + $this->setIfExists('event', $data ?? [], null); + $this->setIfExists('account', $data ?? [], null); + $this->setIfExists('signature_request', $data ?? [], null); + $this->setIfExists('template', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): EventCallbackRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): EventCallbackRequest { - /** @var EventCallbackRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var EventCallbackRequest */ + return ObjectSerializer::deserialize( $data, EventCallbackRequest::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -229,7 +307,6 @@ public function listInvalidProperties() if ($this->container['event'] === null) { $invalidProperties[] = "'event' can't be null"; } - return $invalidProperties; } @@ -263,6 +340,9 @@ public function getEvent() */ public function setEvent(EventCallbackRequestEvent $event) { + if (is_null($event)) { + throw new InvalidArgumentException('non-nullable event cannot be null'); + } $this->container['event'] = $event; return $this; @@ -287,6 +367,9 @@ public function getAccount() */ public function setAccount(?AccountResponse $account) { + if (is_null($account)) { + throw new InvalidArgumentException('non-nullable account cannot be null'); + } $this->container['account'] = $account; return $this; @@ -311,6 +394,9 @@ public function getSignatureRequest() */ public function setSignatureRequest(?SignatureRequestResponse $signature_request) { + if (is_null($signature_request)) { + throw new InvalidArgumentException('non-nullable signature_request cannot be null'); + } $this->container['signature_request'] = $signature_request; return $this; @@ -335,6 +421,9 @@ public function getTemplate() */ public function setTemplate(?TemplateResponse $template) { + if (is_null($template)) { + throw new InvalidArgumentException('non-nullable template cannot be null'); + } $this->container['template'] = $template; return $this; @@ -343,12 +432,10 @@ public function setTemplate(?TemplateResponse $template) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -356,7 +443,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -369,13 +456,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -387,12 +472,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -401,8 +484,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/EventCallbackRequestEvent.php b/sdks/php/src/Model/EventCallbackRequestEvent.php index 0b1ba4d3d..36d99c767 100644 --- a/sdks/php/src/Model/EventCallbackRequestEvent.php +++ b/sdks/php/src/Model/EventCallbackRequestEvent.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -39,11 +38,8 @@ * * @category Class * @description Basic information about the event that occurred. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class EventCallbackRequestEvent implements ModelInterface, ArrayAccess, JsonSerializable { @@ -82,6 +78,25 @@ class EventCallbackRequestEvent implements ModelInterface, ArrayAccess, JsonSeri 'event_metadata' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'event_time' => false, + 'event_type' => false, + 'event_hash' => false, + 'event_metadata' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -102,6 +117,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -241,40 +300,58 @@ public function getEventTypeAllowableValues() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['event_time'] = $data['event_time'] ?? null; - $this->container['event_type'] = $data['event_type'] ?? null; - $this->container['event_hash'] = $data['event_hash'] ?? null; - $this->container['event_metadata'] = $data['event_metadata'] ?? null; + $this->setIfExists('event_time', $data ?? [], null); + $this->setIfExists('event_type', $data ?? [], null); + $this->setIfExists('event_hash', $data ?? [], null); + $this->setIfExists('event_metadata', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): EventCallbackRequestEvent { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): EventCallbackRequestEvent { - /** @var EventCallbackRequestEvent $obj */ - $obj = ObjectSerializer::deserialize( + /** @var EventCallbackRequestEvent */ + return ObjectSerializer::deserialize( $data, EventCallbackRequestEvent::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -304,7 +381,6 @@ public function listInvalidProperties() if ($this->container['event_hash'] === null) { $invalidProperties[] = "'event_hash' can't be null"; } - return $invalidProperties; } @@ -338,6 +414,9 @@ public function getEventTime() */ public function setEventTime(string $event_time) { + if (is_null($event_time)) { + throw new InvalidArgumentException('non-nullable event_time cannot be null'); + } $this->container['event_time'] = $event_time; return $this; @@ -362,6 +441,9 @@ public function getEventType() */ public function setEventType(string $event_type) { + if (is_null($event_type)) { + throw new InvalidArgumentException('non-nullable event_type cannot be null'); + } $allowedValues = $this->getEventTypeAllowableValues(); if (!in_array($event_type, $allowedValues, true)) { throw new InvalidArgumentException( @@ -396,6 +478,9 @@ public function getEventHash() */ public function setEventHash(string $event_hash) { + if (is_null($event_hash)) { + throw new InvalidArgumentException('non-nullable event_hash cannot be null'); + } $this->container['event_hash'] = $event_hash; return $this; @@ -420,6 +505,9 @@ public function getEventMetadata() */ public function setEventMetadata(?EventCallbackRequestEventMetadata $event_metadata) { + if (is_null($event_metadata)) { + throw new InvalidArgumentException('non-nullable event_metadata cannot be null'); + } $this->container['event_metadata'] = $event_metadata; return $this; @@ -428,12 +516,10 @@ public function setEventMetadata(?EventCallbackRequestEventMetadata $event_metad /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -441,7 +527,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -454,13 +540,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -472,12 +556,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -486,8 +568,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/EventCallbackRequestEventMetadata.php b/sdks/php/src/Model/EventCallbackRequestEventMetadata.php index d2b207b08..c0d665c8c 100644 --- a/sdks/php/src/Model/EventCallbackRequestEventMetadata.php +++ b/sdks/php/src/Model/EventCallbackRequestEventMetadata.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -38,11 +37,8 @@ * * @category Class * @description Specific metadata about the event. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class EventCallbackRequestEventMetadata implements ModelInterface, ArrayAccess, JsonSerializable { @@ -81,6 +77,25 @@ class EventCallbackRequestEventMetadata implements ModelInterface, ArrayAccess, 'event_message' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'related_signature_id' => true, + 'reported_for_account_id' => true, + 'reported_for_app_id' => true, + 'event_message' => true, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -101,6 +116,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -182,40 +241,58 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['related_signature_id'] = $data['related_signature_id'] ?? null; - $this->container['reported_for_account_id'] = $data['reported_for_account_id'] ?? null; - $this->container['reported_for_app_id'] = $data['reported_for_app_id'] ?? null; - $this->container['event_message'] = $data['event_message'] ?? null; + $this->setIfExists('related_signature_id', $data ?? [], null); + $this->setIfExists('reported_for_account_id', $data ?? [], null); + $this->setIfExists('reported_for_app_id', $data ?? [], null); + $this->setIfExists('event_message', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): EventCallbackRequestEventMetadata { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): EventCallbackRequestEventMetadata { - /** @var EventCallbackRequestEventMetadata $obj */ - $obj = ObjectSerializer::deserialize( + /** @var EventCallbackRequestEventMetadata */ + return ObjectSerializer::deserialize( $data, EventCallbackRequestEventMetadata::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -225,9 +302,7 @@ public static function init(array $data): EventCallbackRequestEventMetadata */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -260,6 +335,16 @@ public function getRelatedSignatureId() */ public function setRelatedSignatureId(?string $related_signature_id) { + if (is_null($related_signature_id)) { + array_push($this->openAPINullablesSetToNull, 'related_signature_id'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('related_signature_id', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['related_signature_id'] = $related_signature_id; return $this; @@ -284,6 +369,16 @@ public function getReportedForAccountId() */ public function setReportedForAccountId(?string $reported_for_account_id) { + if (is_null($reported_for_account_id)) { + array_push($this->openAPINullablesSetToNull, 'reported_for_account_id'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('reported_for_account_id', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['reported_for_account_id'] = $reported_for_account_id; return $this; @@ -308,6 +403,16 @@ public function getReportedForAppId() */ public function setReportedForAppId(?string $reported_for_app_id) { + if (is_null($reported_for_app_id)) { + array_push($this->openAPINullablesSetToNull, 'reported_for_app_id'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('reported_for_app_id', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['reported_for_app_id'] = $reported_for_app_id; return $this; @@ -332,6 +437,16 @@ public function getEventMessage() */ public function setEventMessage(?string $event_message) { + if (is_null($event_message)) { + array_push($this->openAPINullablesSetToNull, 'event_message'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('event_message', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['event_message'] = $event_message; return $this; @@ -340,12 +455,10 @@ public function setEventMessage(?string $event_message) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -353,7 +466,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -366,13 +479,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -384,12 +495,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -398,8 +507,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/FaxLineAddUserRequest.php b/sdks/php/src/Model/FaxLineAddUserRequest.php index 02c975ca4..b7e2c849a 100644 --- a/sdks/php/src/Model/FaxLineAddUserRequest.php +++ b/sdks/php/src/Model/FaxLineAddUserRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * FaxLineAddUserRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class FaxLineAddUserRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -78,6 +75,24 @@ class FaxLineAddUserRequest implements ModelInterface, ArrayAccess, JsonSerializ 'email_address' => 'email', ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'number' => false, + 'account_id' => false, + 'email_address' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -98,6 +113,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -176,39 +235,57 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['number'] = $data['number'] ?? null; - $this->container['account_id'] = $data['account_id'] ?? null; - $this->container['email_address'] = $data['email_address'] ?? null; + $this->setIfExists('number', $data ?? [], null); + $this->setIfExists('account_id', $data ?? [], null); + $this->setIfExists('email_address', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): FaxLineAddUserRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): FaxLineAddUserRequest { - /** @var FaxLineAddUserRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var FaxLineAddUserRequest */ + return ObjectSerializer::deserialize( $data, FaxLineAddUserRequest::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -223,7 +300,6 @@ public function listInvalidProperties() if ($this->container['number'] === null) { $invalidProperties[] = "'number' can't be null"; } - return $invalidProperties; } @@ -257,6 +333,9 @@ public function getNumber() */ public function setNumber(string $number) { + if (is_null($number)) { + throw new InvalidArgumentException('non-nullable number cannot be null'); + } $this->container['number'] = $number; return $this; @@ -281,6 +360,9 @@ public function getAccountId() */ public function setAccountId(?string $account_id) { + if (is_null($account_id)) { + throw new InvalidArgumentException('non-nullable account_id cannot be null'); + } $this->container['account_id'] = $account_id; return $this; @@ -305,6 +387,9 @@ public function getEmailAddress() */ public function setEmailAddress(?string $email_address) { + if (is_null($email_address)) { + throw new InvalidArgumentException('non-nullable email_address cannot be null'); + } $this->container['email_address'] = $email_address; return $this; @@ -313,12 +398,10 @@ public function setEmailAddress(?string $email_address) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -326,7 +409,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -339,13 +422,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -357,12 +438,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -371,8 +450,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/FaxLineAreaCodeGetCountryEnum.php b/sdks/php/src/Model/FaxLineAreaCodeGetCountryEnum.php index d310fb693..1b96f68c7 100644 --- a/sdks/php/src/Model/FaxLineAreaCodeGetCountryEnum.php +++ b/sdks/php/src/Model/FaxLineAreaCodeGetCountryEnum.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -32,7 +31,6 @@ * FaxLineAreaCodeGetCountryEnum Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ class FaxLineAreaCodeGetCountryEnum diff --git a/sdks/php/src/Model/FaxLineAreaCodeGetProvinceEnum.php b/sdks/php/src/Model/FaxLineAreaCodeGetProvinceEnum.php index 4342c33ce..8bfde8747 100644 --- a/sdks/php/src/Model/FaxLineAreaCodeGetProvinceEnum.php +++ b/sdks/php/src/Model/FaxLineAreaCodeGetProvinceEnum.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -32,7 +31,6 @@ * FaxLineAreaCodeGetProvinceEnum Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ class FaxLineAreaCodeGetProvinceEnum diff --git a/sdks/php/src/Model/FaxLineAreaCodeGetResponse.php b/sdks/php/src/Model/FaxLineAreaCodeGetResponse.php index 502d55db5..60822162d 100644 --- a/sdks/php/src/Model/FaxLineAreaCodeGetResponse.php +++ b/sdks/php/src/Model/FaxLineAreaCodeGetResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * FaxLineAreaCodeGetResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class FaxLineAreaCodeGetResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -75,6 +71,22 @@ class FaxLineAreaCodeGetResponse implements ModelInterface, ArrayAccess, JsonSer 'area_codes' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'area_codes' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -95,6 +107,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -167,37 +223,55 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['area_codes'] = $data['area_codes'] ?? null; + $this->setIfExists('area_codes', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): FaxLineAreaCodeGetResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): FaxLineAreaCodeGetResponse { - /** @var FaxLineAreaCodeGetResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var FaxLineAreaCodeGetResponse */ + return ObjectSerializer::deserialize( $data, FaxLineAreaCodeGetResponse::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -207,9 +281,7 @@ public static function init(array $data): FaxLineAreaCodeGetResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -242,6 +314,9 @@ public function getAreaCodes() */ public function setAreaCodes(?array $area_codes) { + if (is_null($area_codes)) { + throw new InvalidArgumentException('non-nullable area_codes cannot be null'); + } $this->container['area_codes'] = $area_codes; return $this; @@ -250,12 +325,10 @@ public function setAreaCodes(?array $area_codes) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -263,7 +336,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -276,13 +349,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -294,12 +365,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -308,8 +377,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/FaxLineAreaCodeGetStateEnum.php b/sdks/php/src/Model/FaxLineAreaCodeGetStateEnum.php index 14e49fe85..db4f35fd0 100644 --- a/sdks/php/src/Model/FaxLineAreaCodeGetStateEnum.php +++ b/sdks/php/src/Model/FaxLineAreaCodeGetStateEnum.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -32,7 +31,6 @@ * FaxLineAreaCodeGetStateEnum Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ class FaxLineAreaCodeGetStateEnum diff --git a/sdks/php/src/Model/FaxLineCreateRequest.php b/sdks/php/src/Model/FaxLineCreateRequest.php index cda0fe017..a898fef9d 100644 --- a/sdks/php/src/Model/FaxLineCreateRequest.php +++ b/sdks/php/src/Model/FaxLineCreateRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -38,11 +37,8 @@ * FaxLineCreateRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class FaxLineCreateRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -81,6 +77,25 @@ class FaxLineCreateRequest implements ModelInterface, ArrayAccess, JsonSerializa 'account_id' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'area_code' => false, + 'country' => false, + 'city' => false, + 'account_id' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -101,6 +116,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -200,40 +259,58 @@ public function getCountryAllowableValues() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['area_code'] = $data['area_code'] ?? null; - $this->container['country'] = $data['country'] ?? null; - $this->container['city'] = $data['city'] ?? null; - $this->container['account_id'] = $data['account_id'] ?? null; + $this->setIfExists('area_code', $data ?? [], null); + $this->setIfExists('country', $data ?? [], null); + $this->setIfExists('city', $data ?? [], null); + $this->setIfExists('account_id', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): FaxLineCreateRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): FaxLineCreateRequest { - /** @var FaxLineCreateRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var FaxLineCreateRequest */ + return ObjectSerializer::deserialize( $data, FaxLineCreateRequest::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -293,6 +370,9 @@ public function getAreaCode() */ public function setAreaCode(int $area_code) { + if (is_null($area_code)) { + throw new InvalidArgumentException('non-nullable area_code cannot be null'); + } $this->container['area_code'] = $area_code; return $this; @@ -317,6 +397,9 @@ public function getCountry() */ public function setCountry(string $country) { + if (is_null($country)) { + throw new InvalidArgumentException('non-nullable country cannot be null'); + } $allowedValues = $this->getCountryAllowableValues(); if (!in_array($country, $allowedValues, true)) { throw new InvalidArgumentException( @@ -351,6 +434,9 @@ public function getCity() */ public function setCity(?string $city) { + if (is_null($city)) { + throw new InvalidArgumentException('non-nullable city cannot be null'); + } $this->container['city'] = $city; return $this; @@ -375,6 +461,9 @@ public function getAccountId() */ public function setAccountId(?string $account_id) { + if (is_null($account_id)) { + throw new InvalidArgumentException('non-nullable account_id cannot be null'); + } $this->container['account_id'] = $account_id; return $this; @@ -383,12 +472,10 @@ public function setAccountId(?string $account_id) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -396,7 +483,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -409,13 +496,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -427,12 +512,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -441,8 +524,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/FaxLineDeleteRequest.php b/sdks/php/src/Model/FaxLineDeleteRequest.php index cb3152aa8..1fc4fa4a6 100644 --- a/sdks/php/src/Model/FaxLineDeleteRequest.php +++ b/sdks/php/src/Model/FaxLineDeleteRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * FaxLineDeleteRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class FaxLineDeleteRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -74,6 +71,22 @@ class FaxLineDeleteRequest implements ModelInterface, ArrayAccess, JsonSerializa 'number' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'number' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -94,6 +107,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -166,37 +223,55 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['number'] = $data['number'] ?? null; + $this->setIfExists('number', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): FaxLineDeleteRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): FaxLineDeleteRequest { - /** @var FaxLineDeleteRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var FaxLineDeleteRequest */ + return ObjectSerializer::deserialize( $data, FaxLineDeleteRequest::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -211,7 +286,6 @@ public function listInvalidProperties() if ($this->container['number'] === null) { $invalidProperties[] = "'number' can't be null"; } - return $invalidProperties; } @@ -245,6 +319,9 @@ public function getNumber() */ public function setNumber(string $number) { + if (is_null($number)) { + throw new InvalidArgumentException('non-nullable number cannot be null'); + } $this->container['number'] = $number; return $this; @@ -253,12 +330,10 @@ public function setNumber(string $number) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -266,7 +341,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -279,13 +354,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -297,12 +370,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -311,8 +382,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/FaxLineListResponse.php b/sdks/php/src/Model/FaxLineListResponse.php index 18c13f69c..8142c27ff 100644 --- a/sdks/php/src/Model/FaxLineListResponse.php +++ b/sdks/php/src/Model/FaxLineListResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * FaxLineListResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class FaxLineListResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -79,6 +75,24 @@ class FaxLineListResponse implements ModelInterface, ArrayAccess, JsonSerializab 'warnings' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'list_info' => false, + 'fax_lines' => false, + 'warnings' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -99,6 +113,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -177,39 +235,57 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['list_info'] = $data['list_info'] ?? null; - $this->container['fax_lines'] = $data['fax_lines'] ?? null; - $this->container['warnings'] = $data['warnings'] ?? null; + $this->setIfExists('list_info', $data ?? [], null); + $this->setIfExists('fax_lines', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): FaxLineListResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): FaxLineListResponse { - /** @var FaxLineListResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var FaxLineListResponse */ + return ObjectSerializer::deserialize( $data, FaxLineListResponse::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -219,9 +295,7 @@ public static function init(array $data): FaxLineListResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -254,6 +328,9 @@ public function getListInfo() */ public function setListInfo(?ListInfoResponse $list_info) { + if (is_null($list_info)) { + throw new InvalidArgumentException('non-nullable list_info cannot be null'); + } $this->container['list_info'] = $list_info; return $this; @@ -278,6 +355,9 @@ public function getFaxLines() */ public function setFaxLines(?array $fax_lines) { + if (is_null($fax_lines)) { + throw new InvalidArgumentException('non-nullable fax_lines cannot be null'); + } $this->container['fax_lines'] = $fax_lines; return $this; @@ -302,6 +382,9 @@ public function getWarnings() */ public function setWarnings(?WarningResponse $warnings) { + if (is_null($warnings)) { + throw new InvalidArgumentException('non-nullable warnings cannot be null'); + } $this->container['warnings'] = $warnings; return $this; @@ -310,12 +393,10 @@ public function setWarnings(?WarningResponse $warnings) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -323,7 +404,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -336,13 +417,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -354,12 +433,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -368,8 +445,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/FaxLineRemoveUserRequest.php b/sdks/php/src/Model/FaxLineRemoveUserRequest.php index fcc2b1f97..5bec49060 100644 --- a/sdks/php/src/Model/FaxLineRemoveUserRequest.php +++ b/sdks/php/src/Model/FaxLineRemoveUserRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * FaxLineRemoveUserRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class FaxLineRemoveUserRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -78,6 +75,24 @@ class FaxLineRemoveUserRequest implements ModelInterface, ArrayAccess, JsonSeria 'email_address' => 'email', ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'number' => false, + 'account_id' => false, + 'email_address' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -98,6 +113,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -176,39 +235,57 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['number'] = $data['number'] ?? null; - $this->container['account_id'] = $data['account_id'] ?? null; - $this->container['email_address'] = $data['email_address'] ?? null; + $this->setIfExists('number', $data ?? [], null); + $this->setIfExists('account_id', $data ?? [], null); + $this->setIfExists('email_address', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): FaxLineRemoveUserRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): FaxLineRemoveUserRequest { - /** @var FaxLineRemoveUserRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var FaxLineRemoveUserRequest */ + return ObjectSerializer::deserialize( $data, FaxLineRemoveUserRequest::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -223,7 +300,6 @@ public function listInvalidProperties() if ($this->container['number'] === null) { $invalidProperties[] = "'number' can't be null"; } - return $invalidProperties; } @@ -257,6 +333,9 @@ public function getNumber() */ public function setNumber(string $number) { + if (is_null($number)) { + throw new InvalidArgumentException('non-nullable number cannot be null'); + } $this->container['number'] = $number; return $this; @@ -281,6 +360,9 @@ public function getAccountId() */ public function setAccountId(?string $account_id) { + if (is_null($account_id)) { + throw new InvalidArgumentException('non-nullable account_id cannot be null'); + } $this->container['account_id'] = $account_id; return $this; @@ -305,6 +387,9 @@ public function getEmailAddress() */ public function setEmailAddress(?string $email_address) { + if (is_null($email_address)) { + throw new InvalidArgumentException('non-nullable email_address cannot be null'); + } $this->container['email_address'] = $email_address; return $this; @@ -313,12 +398,10 @@ public function setEmailAddress(?string $email_address) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -326,7 +409,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -339,13 +422,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -357,12 +438,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -371,8 +450,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/FaxLineResponse.php b/sdks/php/src/Model/FaxLineResponse.php index f8676d7b0..d9b058a14 100644 --- a/sdks/php/src/Model/FaxLineResponse.php +++ b/sdks/php/src/Model/FaxLineResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * FaxLineResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class FaxLineResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -77,6 +73,23 @@ class FaxLineResponse implements ModelInterface, ArrayAccess, JsonSerializable 'warnings' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'fax_line' => false, + 'warnings' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -97,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -172,38 +229,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['fax_line'] = $data['fax_line'] ?? null; - $this->container['warnings'] = $data['warnings'] ?? null; + $this->setIfExists('fax_line', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): FaxLineResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): FaxLineResponse { - /** @var FaxLineResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var FaxLineResponse */ + return ObjectSerializer::deserialize( $data, FaxLineResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -213,9 +288,7 @@ public static function init(array $data): FaxLineResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -248,6 +321,9 @@ public function getFaxLine() */ public function setFaxLine(?FaxLineResponseFaxLine $fax_line) { + if (is_null($fax_line)) { + throw new InvalidArgumentException('non-nullable fax_line cannot be null'); + } $this->container['fax_line'] = $fax_line; return $this; @@ -272,6 +348,9 @@ public function getWarnings() */ public function setWarnings(?WarningResponse $warnings) { + if (is_null($warnings)) { + throw new InvalidArgumentException('non-nullable warnings cannot be null'); + } $this->container['warnings'] = $warnings; return $this; @@ -280,12 +359,10 @@ public function setWarnings(?WarningResponse $warnings) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -293,7 +370,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -306,13 +383,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -324,12 +399,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -338,8 +411,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/FaxLineResponseFaxLine.php b/sdks/php/src/Model/FaxLineResponseFaxLine.php index 6ccc2ddf5..4a3fe8fa7 100644 --- a/sdks/php/src/Model/FaxLineResponseFaxLine.php +++ b/sdks/php/src/Model/FaxLineResponseFaxLine.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * FaxLineResponseFaxLine Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class FaxLineResponseFaxLine implements ModelInterface, ArrayAccess, JsonSerializable { @@ -81,6 +77,25 @@ class FaxLineResponseFaxLine implements ModelInterface, ArrayAccess, JsonSeriali 'accounts' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'number' => false, + 'created_at' => false, + 'updated_at' => false, + 'accounts' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -101,6 +116,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -182,40 +241,58 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['number'] = $data['number'] ?? null; - $this->container['created_at'] = $data['created_at'] ?? null; - $this->container['updated_at'] = $data['updated_at'] ?? null; - $this->container['accounts'] = $data['accounts'] ?? null; + $this->setIfExists('number', $data ?? [], null); + $this->setIfExists('created_at', $data ?? [], null); + $this->setIfExists('updated_at', $data ?? [], null); + $this->setIfExists('accounts', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): FaxLineResponseFaxLine { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): FaxLineResponseFaxLine { - /** @var FaxLineResponseFaxLine $obj */ - $obj = ObjectSerializer::deserialize( + /** @var FaxLineResponseFaxLine */ + return ObjectSerializer::deserialize( $data, FaxLineResponseFaxLine::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -225,9 +302,7 @@ public static function init(array $data): FaxLineResponseFaxLine */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -260,6 +335,9 @@ public function getNumber() */ public function setNumber(?string $number) { + if (is_null($number)) { + throw new InvalidArgumentException('non-nullable number cannot be null'); + } $this->container['number'] = $number; return $this; @@ -284,6 +362,9 @@ public function getCreatedAt() */ public function setCreatedAt(?int $created_at) { + if (is_null($created_at)) { + throw new InvalidArgumentException('non-nullable created_at cannot be null'); + } $this->container['created_at'] = $created_at; return $this; @@ -308,6 +389,9 @@ public function getUpdatedAt() */ public function setUpdatedAt(?int $updated_at) { + if (is_null($updated_at)) { + throw new InvalidArgumentException('non-nullable updated_at cannot be null'); + } $this->container['updated_at'] = $updated_at; return $this; @@ -332,6 +416,9 @@ public function getAccounts() */ public function setAccounts(?array $accounts) { + if (is_null($accounts)) { + throw new InvalidArgumentException('non-nullable accounts cannot be null'); + } $this->container['accounts'] = $accounts; return $this; @@ -340,12 +427,10 @@ public function setAccounts(?array $accounts) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -353,7 +438,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -366,13 +451,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -384,12 +467,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -398,8 +479,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/FileResponse.php b/sdks/php/src/Model/FileResponse.php index 62c76b97e..8476fad5b 100644 --- a/sdks/php/src/Model/FileResponse.php +++ b/sdks/php/src/Model/FileResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * FileResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class FileResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -77,6 +73,23 @@ class FileResponse implements ModelInterface, ArrayAccess, JsonSerializable 'expires_at' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'file_url' => false, + 'expires_at' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -97,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -172,38 +229,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['file_url'] = $data['file_url'] ?? null; - $this->container['expires_at'] = $data['expires_at'] ?? null; + $this->setIfExists('file_url', $data ?? [], null); + $this->setIfExists('expires_at', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): FileResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): FileResponse { - /** @var FileResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var FileResponse */ + return ObjectSerializer::deserialize( $data, FileResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -213,9 +288,7 @@ public static function init(array $data): FileResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -248,6 +321,9 @@ public function getFileUrl() */ public function setFileUrl(?string $file_url) { + if (is_null($file_url)) { + throw new InvalidArgumentException('non-nullable file_url cannot be null'); + } $this->container['file_url'] = $file_url; return $this; @@ -272,6 +348,9 @@ public function getExpiresAt() */ public function setExpiresAt(?int $expires_at) { + if (is_null($expires_at)) { + throw new InvalidArgumentException('non-nullable expires_at cannot be null'); + } $this->container['expires_at'] = $expires_at; return $this; @@ -280,12 +359,10 @@ public function setExpiresAt(?int $expires_at) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -293,7 +370,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -306,13 +383,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -324,12 +399,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -338,8 +411,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/FileResponseDataUri.php b/sdks/php/src/Model/FileResponseDataUri.php index 1ff596a9a..9c028c39f 100644 --- a/sdks/php/src/Model/FileResponseDataUri.php +++ b/sdks/php/src/Model/FileResponseDataUri.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * FileResponseDataUri Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class FileResponseDataUri implements ModelInterface, ArrayAccess, JsonSerializable { @@ -75,6 +71,22 @@ class FileResponseDataUri implements ModelInterface, ArrayAccess, JsonSerializab 'data_uri' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'data_uri' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -95,6 +107,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -167,37 +223,55 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['data_uri'] = $data['data_uri'] ?? null; + $this->setIfExists('data_uri', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): FileResponseDataUri { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): FileResponseDataUri { - /** @var FileResponseDataUri $obj */ - $obj = ObjectSerializer::deserialize( + /** @var FileResponseDataUri */ + return ObjectSerializer::deserialize( $data, FileResponseDataUri::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -207,9 +281,7 @@ public static function init(array $data): FileResponseDataUri */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -242,6 +314,9 @@ public function getDataUri() */ public function setDataUri(?string $data_uri) { + if (is_null($data_uri)) { + throw new InvalidArgumentException('non-nullable data_uri cannot be null'); + } $this->container['data_uri'] = $data_uri; return $this; @@ -250,12 +325,10 @@ public function setDataUri(?string $data_uri) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -263,7 +336,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -276,13 +349,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -294,12 +365,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -308,8 +377,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/ListInfoResponse.php b/sdks/php/src/Model/ListInfoResponse.php index 33100c388..623284e41 100644 --- a/sdks/php/src/Model/ListInfoResponse.php +++ b/sdks/php/src/Model/ListInfoResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,12 +38,8 @@ * * @category Class * @description Contains pagination information about the data returned. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class ListInfoResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -82,6 +78,25 @@ class ListInfoResponse implements ModelInterface, ArrayAccess, JsonSerializable 'page_size' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'num_pages' => false, + 'num_results' => true, + 'page' => false, + 'page_size' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -102,6 +117,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -183,40 +242,58 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['num_pages'] = $data['num_pages'] ?? null; - $this->container['num_results'] = $data['num_results'] ?? null; - $this->container['page'] = $data['page'] ?? null; - $this->container['page_size'] = $data['page_size'] ?? null; + $this->setIfExists('num_pages', $data ?? [], null); + $this->setIfExists('num_results', $data ?? [], null); + $this->setIfExists('page', $data ?? [], null); + $this->setIfExists('page_size', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): ListInfoResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): ListInfoResponse { - /** @var ListInfoResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var ListInfoResponse */ + return ObjectSerializer::deserialize( $data, ListInfoResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -226,9 +303,7 @@ public static function init(array $data): ListInfoResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -261,6 +336,9 @@ public function getNumPages() */ public function setNumPages(?int $num_pages) { + if (is_null($num_pages)) { + throw new InvalidArgumentException('non-nullable num_pages cannot be null'); + } $this->container['num_pages'] = $num_pages; return $this; @@ -285,6 +363,16 @@ public function getNumResults() */ public function setNumResults(?int $num_results) { + if (is_null($num_results)) { + array_push($this->openAPINullablesSetToNull, 'num_results'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('num_results', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['num_results'] = $num_results; return $this; @@ -309,6 +397,9 @@ public function getPage() */ public function setPage(?int $page) { + if (is_null($page)) { + throw new InvalidArgumentException('non-nullable page cannot be null'); + } $this->container['page'] = $page; return $this; @@ -333,6 +424,9 @@ public function getPageSize() */ public function setPageSize(?int $page_size) { + if (is_null($page_size)) { + throw new InvalidArgumentException('non-nullable page_size cannot be null'); + } $this->container['page_size'] = $page_size; return $this; @@ -341,12 +435,10 @@ public function setPageSize(?int $page_size) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -354,7 +446,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -367,13 +459,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -385,12 +475,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -399,8 +487,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/ModelInterface.php b/sdks/php/src/Model/ModelInterface.php index c26c5c647..0bc2f212e 100644 --- a/sdks/php/src/Model/ModelInterface.php +++ b/sdks/php/src/Model/ModelInterface.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,8 +29,6 @@ /** * Interface abstracting model access. - * - * @author OpenAPI Generator team */ interface ModelInterface { @@ -91,4 +88,14 @@ public function listInvalidProperties(); * @return bool */ public function valid(); + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool; + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool; } diff --git a/sdks/php/src/Model/OAuthTokenGenerateRequest.php b/sdks/php/src/Model/OAuthTokenGenerateRequest.php index 3c23513e9..38a0395d1 100644 --- a/sdks/php/src/Model/OAuthTokenGenerateRequest.php +++ b/sdks/php/src/Model/OAuthTokenGenerateRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * OAuthTokenGenerateRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class OAuthTokenGenerateRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -82,6 +79,26 @@ class OAuthTokenGenerateRequest implements ModelInterface, ArrayAccess, JsonSeri 'state' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'client_id' => false, + 'client_secret' => false, + 'code' => false, + 'grant_type' => false, + 'state' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -102,6 +119,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -186,41 +247,59 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['client_id'] = $data['client_id'] ?? null; - $this->container['client_secret'] = $data['client_secret'] ?? null; - $this->container['code'] = $data['code'] ?? null; - $this->container['grant_type'] = $data['grant_type'] ?? 'authorization_code'; - $this->container['state'] = $data['state'] ?? null; + $this->setIfExists('client_id', $data ?? [], null); + $this->setIfExists('client_secret', $data ?? [], null); + $this->setIfExists('code', $data ?? [], null); + $this->setIfExists('grant_type', $data ?? [], 'authorization_code'); + $this->setIfExists('state', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): OAuthTokenGenerateRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): OAuthTokenGenerateRequest { - /** @var OAuthTokenGenerateRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var OAuthTokenGenerateRequest */ + return ObjectSerializer::deserialize( $data, OAuthTokenGenerateRequest::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -247,7 +326,6 @@ public function listInvalidProperties() if ($this->container['state'] === null) { $invalidProperties[] = "'state' can't be null"; } - return $invalidProperties; } @@ -281,6 +359,9 @@ public function getClientId() */ public function setClientId(string $client_id) { + if (is_null($client_id)) { + throw new InvalidArgumentException('non-nullable client_id cannot be null'); + } $this->container['client_id'] = $client_id; return $this; @@ -305,6 +386,9 @@ public function getClientSecret() */ public function setClientSecret(string $client_secret) { + if (is_null($client_secret)) { + throw new InvalidArgumentException('non-nullable client_secret cannot be null'); + } $this->container['client_secret'] = $client_secret; return $this; @@ -329,6 +413,9 @@ public function getCode() */ public function setCode(string $code) { + if (is_null($code)) { + throw new InvalidArgumentException('non-nullable code cannot be null'); + } $this->container['code'] = $code; return $this; @@ -353,6 +440,9 @@ public function getGrantType() */ public function setGrantType(string $grant_type) { + if (is_null($grant_type)) { + throw new InvalidArgumentException('non-nullable grant_type cannot be null'); + } $this->container['grant_type'] = $grant_type; return $this; @@ -377,6 +467,9 @@ public function getState() */ public function setState(string $state) { + if (is_null($state)) { + throw new InvalidArgumentException('non-nullable state cannot be null'); + } $this->container['state'] = $state; return $this; @@ -385,12 +478,10 @@ public function setState(string $state) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -398,7 +489,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -411,13 +502,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -429,12 +518,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -443,8 +530,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/OAuthTokenRefreshRequest.php b/sdks/php/src/Model/OAuthTokenRefreshRequest.php index 5bd36eb93..c4c7f93be 100644 --- a/sdks/php/src/Model/OAuthTokenRefreshRequest.php +++ b/sdks/php/src/Model/OAuthTokenRefreshRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * OAuthTokenRefreshRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class OAuthTokenRefreshRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -76,6 +73,23 @@ class OAuthTokenRefreshRequest implements ModelInterface, ArrayAccess, JsonSeria 'refresh_token' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'grant_type' => false, + 'refresh_token' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -96,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -171,38 +229,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['grant_type'] = $data['grant_type'] ?? 'refresh_token'; - $this->container['refresh_token'] = $data['refresh_token'] ?? null; + $this->setIfExists('grant_type', $data ?? [], 'refresh_token'); + $this->setIfExists('refresh_token', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): OAuthTokenRefreshRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): OAuthTokenRefreshRequest { - /** @var OAuthTokenRefreshRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var OAuthTokenRefreshRequest */ + return ObjectSerializer::deserialize( $data, OAuthTokenRefreshRequest::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -220,7 +296,6 @@ public function listInvalidProperties() if ($this->container['refresh_token'] === null) { $invalidProperties[] = "'refresh_token' can't be null"; } - return $invalidProperties; } @@ -254,6 +329,9 @@ public function getGrantType() */ public function setGrantType(string $grant_type) { + if (is_null($grant_type)) { + throw new InvalidArgumentException('non-nullable grant_type cannot be null'); + } $this->container['grant_type'] = $grant_type; return $this; @@ -278,6 +356,9 @@ public function getRefreshToken() */ public function setRefreshToken(string $refresh_token) { + if (is_null($refresh_token)) { + throw new InvalidArgumentException('non-nullable refresh_token cannot be null'); + } $this->container['refresh_token'] = $refresh_token; return $this; @@ -286,12 +367,10 @@ public function setRefreshToken(string $refresh_token) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -299,7 +378,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -312,13 +391,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -330,12 +407,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -344,8 +419,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/OAuthTokenResponse.php b/sdks/php/src/Model/OAuthTokenResponse.php index 791384e4c..8c83de78e 100644 --- a/sdks/php/src/Model/OAuthTokenResponse.php +++ b/sdks/php/src/Model/OAuthTokenResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * OAuthTokenResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class OAuthTokenResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -83,6 +79,26 @@ class OAuthTokenResponse implements ModelInterface, ArrayAccess, JsonSerializabl 'state' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'access_token' => false, + 'token_type' => false, + 'refresh_token' => false, + 'expires_in' => false, + 'state' => true, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -103,6 +119,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -187,41 +247,59 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['access_token'] = $data['access_token'] ?? null; - $this->container['token_type'] = $data['token_type'] ?? null; - $this->container['refresh_token'] = $data['refresh_token'] ?? null; - $this->container['expires_in'] = $data['expires_in'] ?? null; - $this->container['state'] = $data['state'] ?? null; + $this->setIfExists('access_token', $data ?? [], null); + $this->setIfExists('token_type', $data ?? [], null); + $this->setIfExists('refresh_token', $data ?? [], null); + $this->setIfExists('expires_in', $data ?? [], null); + $this->setIfExists('state', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): OAuthTokenResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): OAuthTokenResponse { - /** @var OAuthTokenResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var OAuthTokenResponse */ + return ObjectSerializer::deserialize( $data, OAuthTokenResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -231,9 +309,7 @@ public static function init(array $data): OAuthTokenResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -266,6 +342,9 @@ public function getAccessToken() */ public function setAccessToken(?string $access_token) { + if (is_null($access_token)) { + throw new InvalidArgumentException('non-nullable access_token cannot be null'); + } $this->container['access_token'] = $access_token; return $this; @@ -290,6 +369,9 @@ public function getTokenType() */ public function setTokenType(?string $token_type) { + if (is_null($token_type)) { + throw new InvalidArgumentException('non-nullable token_type cannot be null'); + } $this->container['token_type'] = $token_type; return $this; @@ -314,6 +396,9 @@ public function getRefreshToken() */ public function setRefreshToken(?string $refresh_token) { + if (is_null($refresh_token)) { + throw new InvalidArgumentException('non-nullable refresh_token cannot be null'); + } $this->container['refresh_token'] = $refresh_token; return $this; @@ -338,6 +423,9 @@ public function getExpiresIn() */ public function setExpiresIn(?int $expires_in) { + if (is_null($expires_in)) { + throw new InvalidArgumentException('non-nullable expires_in cannot be null'); + } $this->container['expires_in'] = $expires_in; return $this; @@ -362,6 +450,16 @@ public function getState() */ public function setState(?string $state) { + if (is_null($state)) { + array_push($this->openAPINullablesSetToNull, 'state'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('state', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['state'] = $state; return $this; @@ -370,12 +468,10 @@ public function setState(?string $state) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -383,7 +479,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -396,13 +492,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -414,12 +508,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -428,8 +520,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/ReportCreateRequest.php b/sdks/php/src/Model/ReportCreateRequest.php index 9d2fbb387..58029634b 100644 --- a/sdks/php/src/Model/ReportCreateRequest.php +++ b/sdks/php/src/Model/ReportCreateRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -38,11 +37,8 @@ * ReportCreateRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class ReportCreateRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -79,6 +75,24 @@ class ReportCreateRequest implements ModelInterface, ArrayAccess, JsonSerializab 'start_date' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'end_date' => false, + 'report_type' => false, + 'start_date' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -99,6 +113,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -193,39 +251,57 @@ public function getReportTypeAllowableValues() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['end_date'] = $data['end_date'] ?? null; - $this->container['report_type'] = $data['report_type'] ?? null; - $this->container['start_date'] = $data['start_date'] ?? null; + $this->setIfExists('end_date', $data ?? [], null); + $this->setIfExists('report_type', $data ?? [], null); + $this->setIfExists('start_date', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): ReportCreateRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): ReportCreateRequest { - /** @var ReportCreateRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var ReportCreateRequest */ + return ObjectSerializer::deserialize( $data, ReportCreateRequest::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -243,18 +319,17 @@ public function listInvalidProperties() if ($this->container['report_type'] === null) { $invalidProperties[] = "'report_type' can't be null"; } - if ((count($this->container['report_type']) > 2)) { + if (count($this->container['report_type']) > 2) { $invalidProperties[] = "invalid value for 'report_type', number of items must be less than or equal to 2."; } - if ((count($this->container['report_type']) < 1)) { + if (count($this->container['report_type']) < 1) { $invalidProperties[] = "invalid value for 'report_type', number of items must be greater than or equal to 1."; } if ($this->container['start_date'] === null) { $invalidProperties[] = "'start_date' can't be null"; } - return $invalidProperties; } @@ -288,6 +363,9 @@ public function getEndDate() */ public function setEndDate(string $end_date) { + if (is_null($end_date)) { + throw new InvalidArgumentException('non-nullable end_date cannot be null'); + } $this->container['end_date'] = $end_date; return $this; @@ -312,6 +390,9 @@ public function getReportType() */ public function setReportType(array $report_type) { + if (is_null($report_type)) { + throw new InvalidArgumentException('non-nullable report_type cannot be null'); + } $allowedValues = $this->getReportTypeAllowableValues(); if (array_diff($report_type, $allowedValues)) { throw new InvalidArgumentException( @@ -322,10 +403,10 @@ public function setReportType(array $report_type) ); } - if ((count($report_type) > 2)) { + if (count($report_type) > 2) { throw new InvalidArgumentException('invalid value for $report_type when calling ReportCreateRequest., number of items must be less than or equal to 2.'); } - if ((count($report_type) < 1)) { + if (count($report_type) < 1) { throw new InvalidArgumentException('invalid length for $report_type when calling ReportCreateRequest., number of items must be greater than or equal to 1.'); } $this->container['report_type'] = $report_type; @@ -352,6 +433,9 @@ public function getStartDate() */ public function setStartDate(string $start_date) { + if (is_null($start_date)) { + throw new InvalidArgumentException('non-nullable start_date cannot be null'); + } $this->container['start_date'] = $start_date; return $this; @@ -360,12 +444,10 @@ public function setStartDate(string $start_date) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -373,7 +455,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -386,13 +468,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -404,12 +484,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -418,8 +496,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/ReportCreateResponse.php b/sdks/php/src/Model/ReportCreateResponse.php index 73f63b485..50384baf4 100644 --- a/sdks/php/src/Model/ReportCreateResponse.php +++ b/sdks/php/src/Model/ReportCreateResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * ReportCreateResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class ReportCreateResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -77,6 +73,23 @@ class ReportCreateResponse implements ModelInterface, ArrayAccess, JsonSerializa 'warnings' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'report' => false, + 'warnings' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -97,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -172,38 +229,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['report'] = $data['report'] ?? null; - $this->container['warnings'] = $data['warnings'] ?? null; + $this->setIfExists('report', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): ReportCreateResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): ReportCreateResponse { - /** @var ReportCreateResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var ReportCreateResponse */ + return ObjectSerializer::deserialize( $data, ReportCreateResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -213,9 +288,7 @@ public static function init(array $data): ReportCreateResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -248,6 +321,9 @@ public function getReport() */ public function setReport(?ReportResponse $report) { + if (is_null($report)) { + throw new InvalidArgumentException('non-nullable report cannot be null'); + } $this->container['report'] = $report; return $this; @@ -272,6 +348,9 @@ public function getWarnings() */ public function setWarnings(?array $warnings) { + if (is_null($warnings)) { + throw new InvalidArgumentException('non-nullable warnings cannot be null'); + } $this->container['warnings'] = $warnings; return $this; @@ -280,12 +359,10 @@ public function setWarnings(?array $warnings) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -293,7 +370,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -306,13 +383,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -324,12 +399,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -338,8 +411,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/ReportResponse.php b/sdks/php/src/Model/ReportResponse.php index 018938b1d..c2d024ca1 100644 --- a/sdks/php/src/Model/ReportResponse.php +++ b/sdks/php/src/Model/ReportResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -39,12 +38,8 @@ * * @category Class * @description Contains information about the report request. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class ReportResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -83,6 +78,25 @@ class ReportResponse implements ModelInterface, ArrayAccess, JsonSerializable 'report_type' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'success' => false, + 'start_date' => false, + 'end_date' => false, + 'report_type' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -103,6 +117,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -200,40 +258,58 @@ public function getReportTypeAllowableValues() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['success'] = $data['success'] ?? null; - $this->container['start_date'] = $data['start_date'] ?? null; - $this->container['end_date'] = $data['end_date'] ?? null; - $this->container['report_type'] = $data['report_type'] ?? null; + $this->setIfExists('success', $data ?? [], null); + $this->setIfExists('start_date', $data ?? [], null); + $this->setIfExists('end_date', $data ?? [], null); + $this->setIfExists('report_type', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): ReportResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): ReportResponse { - /** @var ReportResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var ReportResponse */ + return ObjectSerializer::deserialize( $data, ReportResponse::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -243,9 +319,7 @@ public static function init(array $data): ReportResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -278,6 +352,9 @@ public function getSuccess() */ public function setSuccess(?string $success) { + if (is_null($success)) { + throw new InvalidArgumentException('non-nullable success cannot be null'); + } $this->container['success'] = $success; return $this; @@ -302,6 +379,9 @@ public function getStartDate() */ public function setStartDate(?string $start_date) { + if (is_null($start_date)) { + throw new InvalidArgumentException('non-nullable start_date cannot be null'); + } $this->container['start_date'] = $start_date; return $this; @@ -326,6 +406,9 @@ public function getEndDate() */ public function setEndDate(?string $end_date) { + if (is_null($end_date)) { + throw new InvalidArgumentException('non-nullable end_date cannot be null'); + } $this->container['end_date'] = $end_date; return $this; @@ -350,8 +433,11 @@ public function getReportType() */ public function setReportType(?array $report_type) { + if (is_null($report_type)) { + throw new InvalidArgumentException('non-nullable report_type cannot be null'); + } $allowedValues = $this->getReportTypeAllowableValues(); - if (!is_null($report_type) && array_diff($report_type, $allowedValues)) { + if (array_diff($report_type, $allowedValues)) { throw new InvalidArgumentException( sprintf( "Invalid value for 'report_type', must be one of '%s'", @@ -367,12 +453,10 @@ public function setReportType(?array $report_type) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -380,7 +464,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -393,13 +477,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -411,12 +493,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -425,8 +505,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SignatureRequestBulkCreateEmbeddedWithTemplateRequest.php b/sdks/php/src/Model/SignatureRequestBulkCreateEmbeddedWithTemplateRequest.php index 3be6909ed..9c5947fec 100644 --- a/sdks/php/src/Model/SignatureRequestBulkCreateEmbeddedWithTemplateRequest.php +++ b/sdks/php/src/Model/SignatureRequestBulkCreateEmbeddedWithTemplateRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -39,11 +38,8 @@ * SignatureRequestBulkCreateEmbeddedWithTemplateRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SignatureRequestBulkCreateEmbeddedWithTemplateRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -100,6 +96,34 @@ class SignatureRequestBulkCreateEmbeddedWithTemplateRequest implements ModelInte 'title' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'template_ids' => false, + 'client_id' => false, + 'signer_file' => false, + 'signer_list' => false, + 'allow_decline' => false, + 'ccs' => false, + 'custom_fields' => false, + 'message' => false, + 'metadata' => false, + 'signing_redirect_url' => false, + 'subject' => false, + 'test_mode' => false, + 'title' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -120,6 +144,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -228,49 +296,67 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['template_ids'] = $data['template_ids'] ?? null; - $this->container['client_id'] = $data['client_id'] ?? null; - $this->container['signer_file'] = $data['signer_file'] ?? null; - $this->container['signer_list'] = $data['signer_list'] ?? null; - $this->container['allow_decline'] = $data['allow_decline'] ?? false; - $this->container['ccs'] = $data['ccs'] ?? null; - $this->container['custom_fields'] = $data['custom_fields'] ?? null; - $this->container['message'] = $data['message'] ?? null; - $this->container['metadata'] = $data['metadata'] ?? null; - $this->container['signing_redirect_url'] = $data['signing_redirect_url'] ?? null; - $this->container['subject'] = $data['subject'] ?? null; - $this->container['test_mode'] = $data['test_mode'] ?? false; - $this->container['title'] = $data['title'] ?? null; - } - - /** @deprecated use ::init() */ + $this->setIfExists('template_ids', $data ?? [], null); + $this->setIfExists('client_id', $data ?? [], null); + $this->setIfExists('signer_file', $data ?? [], null); + $this->setIfExists('signer_list', $data ?? [], null); + $this->setIfExists('allow_decline', $data ?? [], false); + $this->setIfExists('ccs', $data ?? [], null); + $this->setIfExists('custom_fields', $data ?? [], null); + $this->setIfExists('message', $data ?? [], null); + $this->setIfExists('metadata', $data ?? [], null); + $this->setIfExists('signing_redirect_url', $data ?? [], null); + $this->setIfExists('subject', $data ?? [], null); + $this->setIfExists('test_mode', $data ?? [], false); + $this->setIfExists('title', $data ?? [], null); + } + + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SignatureRequestBulkCreateEmbeddedWithTemplateRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SignatureRequestBulkCreateEmbeddedWithTemplateRequest { - /** @var SignatureRequestBulkCreateEmbeddedWithTemplateRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SignatureRequestBulkCreateEmbeddedWithTemplateRequest */ + return ObjectSerializer::deserialize( $data, SignatureRequestBulkCreateEmbeddedWithTemplateRequest::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -333,6 +419,9 @@ public function getTemplateIds() */ public function setTemplateIds(array $template_ids) { + if (is_null($template_ids)) { + throw new InvalidArgumentException('non-nullable template_ids cannot be null'); + } $this->container['template_ids'] = $template_ids; return $this; @@ -357,6 +446,9 @@ public function getClientId() */ public function setClientId(string $client_id) { + if (is_null($client_id)) { + throw new InvalidArgumentException('non-nullable client_id cannot be null'); + } $this->container['client_id'] = $client_id; return $this; @@ -381,6 +473,9 @@ public function getSignerFile() */ public function setSignerFile(?SplFileObject $signer_file) { + if (is_null($signer_file)) { + throw new InvalidArgumentException('non-nullable signer_file cannot be null'); + } $this->container['signer_file'] = $signer_file; return $this; @@ -405,6 +500,9 @@ public function getSignerList() */ public function setSignerList(?array $signer_list) { + if (is_null($signer_list)) { + throw new InvalidArgumentException('non-nullable signer_list cannot be null'); + } $this->container['signer_list'] = $signer_list; return $this; @@ -429,6 +527,9 @@ public function getAllowDecline() */ public function setAllowDecline(?bool $allow_decline) { + if (is_null($allow_decline)) { + throw new InvalidArgumentException('non-nullable allow_decline cannot be null'); + } $this->container['allow_decline'] = $allow_decline; return $this; @@ -453,6 +554,9 @@ public function getCcs() */ public function setCcs(?array $ccs) { + if (is_null($ccs)) { + throw new InvalidArgumentException('non-nullable ccs cannot be null'); + } $this->container['ccs'] = $ccs; return $this; @@ -477,6 +581,9 @@ public function getCustomFields() */ public function setCustomFields(?array $custom_fields) { + if (is_null($custom_fields)) { + throw new InvalidArgumentException('non-nullable custom_fields cannot be null'); + } $this->container['custom_fields'] = $custom_fields; return $this; @@ -501,7 +608,10 @@ public function getMessage() */ public function setMessage(?string $message) { - if (!is_null($message) && (mb_strlen($message) > 5000)) { + if (is_null($message)) { + throw new InvalidArgumentException('non-nullable message cannot be null'); + } + if (mb_strlen($message) > 5000) { throw new InvalidArgumentException('invalid length for $message when calling SignatureRequestBulkCreateEmbeddedWithTemplateRequest., must be smaller than or equal to 5000.'); } @@ -529,6 +639,10 @@ public function getMetadata() */ public function setMetadata(?array $metadata) { + if (is_null($metadata)) { + throw new InvalidArgumentException('non-nullable metadata cannot be null'); + } + $this->container['metadata'] = $metadata; return $this; @@ -553,6 +667,9 @@ public function getSigningRedirectUrl() */ public function setSigningRedirectUrl(?string $signing_redirect_url) { + if (is_null($signing_redirect_url)) { + throw new InvalidArgumentException('non-nullable signing_redirect_url cannot be null'); + } $this->container['signing_redirect_url'] = $signing_redirect_url; return $this; @@ -577,7 +694,10 @@ public function getSubject() */ public function setSubject(?string $subject) { - if (!is_null($subject) && (mb_strlen($subject) > 255)) { + if (is_null($subject)) { + throw new InvalidArgumentException('non-nullable subject cannot be null'); + } + if (mb_strlen($subject) > 255) { throw new InvalidArgumentException('invalid length for $subject when calling SignatureRequestBulkCreateEmbeddedWithTemplateRequest., must be smaller than or equal to 255.'); } @@ -605,6 +725,9 @@ public function getTestMode() */ public function setTestMode(?bool $test_mode) { + if (is_null($test_mode)) { + throw new InvalidArgumentException('non-nullable test_mode cannot be null'); + } $this->container['test_mode'] = $test_mode; return $this; @@ -629,7 +752,10 @@ public function getTitle() */ public function setTitle(?string $title) { - if (!is_null($title) && (mb_strlen($title) > 255)) { + if (is_null($title)) { + throw new InvalidArgumentException('non-nullable title cannot be null'); + } + if (mb_strlen($title) > 255) { throw new InvalidArgumentException('invalid length for $title when calling SignatureRequestBulkCreateEmbeddedWithTemplateRequest., must be smaller than or equal to 255.'); } @@ -641,12 +767,10 @@ public function setTitle(?string $title) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -654,7 +778,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -667,13 +791,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -685,12 +807,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -699,8 +819,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SignatureRequestBulkSendWithTemplateRequest.php b/sdks/php/src/Model/SignatureRequestBulkSendWithTemplateRequest.php index b90dbac52..26092eb3f 100644 --- a/sdks/php/src/Model/SignatureRequestBulkSendWithTemplateRequest.php +++ b/sdks/php/src/Model/SignatureRequestBulkSendWithTemplateRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -39,11 +38,8 @@ * SignatureRequestBulkSendWithTemplateRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SignatureRequestBulkSendWithTemplateRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -100,6 +96,34 @@ class SignatureRequestBulkSendWithTemplateRequest implements ModelInterface, Arr 'title' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'template_ids' => false, + 'signer_file' => false, + 'signer_list' => false, + 'allow_decline' => false, + 'ccs' => false, + 'client_id' => false, + 'custom_fields' => false, + 'message' => false, + 'metadata' => false, + 'signing_redirect_url' => false, + 'subject' => false, + 'test_mode' => false, + 'title' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -120,6 +144,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -228,49 +296,67 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['template_ids'] = $data['template_ids'] ?? null; - $this->container['signer_file'] = $data['signer_file'] ?? null; - $this->container['signer_list'] = $data['signer_list'] ?? null; - $this->container['allow_decline'] = $data['allow_decline'] ?? false; - $this->container['ccs'] = $data['ccs'] ?? null; - $this->container['client_id'] = $data['client_id'] ?? null; - $this->container['custom_fields'] = $data['custom_fields'] ?? null; - $this->container['message'] = $data['message'] ?? null; - $this->container['metadata'] = $data['metadata'] ?? null; - $this->container['signing_redirect_url'] = $data['signing_redirect_url'] ?? null; - $this->container['subject'] = $data['subject'] ?? null; - $this->container['test_mode'] = $data['test_mode'] ?? false; - $this->container['title'] = $data['title'] ?? null; - } - - /** @deprecated use ::init() */ + $this->setIfExists('template_ids', $data ?? [], null); + $this->setIfExists('signer_file', $data ?? [], null); + $this->setIfExists('signer_list', $data ?? [], null); + $this->setIfExists('allow_decline', $data ?? [], false); + $this->setIfExists('ccs', $data ?? [], null); + $this->setIfExists('client_id', $data ?? [], null); + $this->setIfExists('custom_fields', $data ?? [], null); + $this->setIfExists('message', $data ?? [], null); + $this->setIfExists('metadata', $data ?? [], null); + $this->setIfExists('signing_redirect_url', $data ?? [], null); + $this->setIfExists('subject', $data ?? [], null); + $this->setIfExists('test_mode', $data ?? [], false); + $this->setIfExists('title', $data ?? [], null); + } + + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SignatureRequestBulkSendWithTemplateRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SignatureRequestBulkSendWithTemplateRequest { - /** @var SignatureRequestBulkSendWithTemplateRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SignatureRequestBulkSendWithTemplateRequest */ + return ObjectSerializer::deserialize( $data, SignatureRequestBulkSendWithTemplateRequest::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -330,6 +416,9 @@ public function getTemplateIds() */ public function setTemplateIds(array $template_ids) { + if (is_null($template_ids)) { + throw new InvalidArgumentException('non-nullable template_ids cannot be null'); + } $this->container['template_ids'] = $template_ids; return $this; @@ -354,6 +443,9 @@ public function getSignerFile() */ public function setSignerFile(?SplFileObject $signer_file) { + if (is_null($signer_file)) { + throw new InvalidArgumentException('non-nullable signer_file cannot be null'); + } $this->container['signer_file'] = $signer_file; return $this; @@ -378,6 +470,9 @@ public function getSignerList() */ public function setSignerList(?array $signer_list) { + if (is_null($signer_list)) { + throw new InvalidArgumentException('non-nullable signer_list cannot be null'); + } $this->container['signer_list'] = $signer_list; return $this; @@ -402,6 +497,9 @@ public function getAllowDecline() */ public function setAllowDecline(?bool $allow_decline) { + if (is_null($allow_decline)) { + throw new InvalidArgumentException('non-nullable allow_decline cannot be null'); + } $this->container['allow_decline'] = $allow_decline; return $this; @@ -426,6 +524,9 @@ public function getCcs() */ public function setCcs(?array $ccs) { + if (is_null($ccs)) { + throw new InvalidArgumentException('non-nullable ccs cannot be null'); + } $this->container['ccs'] = $ccs; return $this; @@ -450,6 +551,9 @@ public function getClientId() */ public function setClientId(?string $client_id) { + if (is_null($client_id)) { + throw new InvalidArgumentException('non-nullable client_id cannot be null'); + } $this->container['client_id'] = $client_id; return $this; @@ -474,6 +578,9 @@ public function getCustomFields() */ public function setCustomFields(?array $custom_fields) { + if (is_null($custom_fields)) { + throw new InvalidArgumentException('non-nullable custom_fields cannot be null'); + } $this->container['custom_fields'] = $custom_fields; return $this; @@ -498,7 +605,10 @@ public function getMessage() */ public function setMessage(?string $message) { - if (!is_null($message) && (mb_strlen($message) > 5000)) { + if (is_null($message)) { + throw new InvalidArgumentException('non-nullable message cannot be null'); + } + if (mb_strlen($message) > 5000) { throw new InvalidArgumentException('invalid length for $message when calling SignatureRequestBulkSendWithTemplateRequest., must be smaller than or equal to 5000.'); } @@ -526,6 +636,10 @@ public function getMetadata() */ public function setMetadata(?array $metadata) { + if (is_null($metadata)) { + throw new InvalidArgumentException('non-nullable metadata cannot be null'); + } + $this->container['metadata'] = $metadata; return $this; @@ -550,6 +664,9 @@ public function getSigningRedirectUrl() */ public function setSigningRedirectUrl(?string $signing_redirect_url) { + if (is_null($signing_redirect_url)) { + throw new InvalidArgumentException('non-nullable signing_redirect_url cannot be null'); + } $this->container['signing_redirect_url'] = $signing_redirect_url; return $this; @@ -574,7 +691,10 @@ public function getSubject() */ public function setSubject(?string $subject) { - if (!is_null($subject) && (mb_strlen($subject) > 255)) { + if (is_null($subject)) { + throw new InvalidArgumentException('non-nullable subject cannot be null'); + } + if (mb_strlen($subject) > 255) { throw new InvalidArgumentException('invalid length for $subject when calling SignatureRequestBulkSendWithTemplateRequest., must be smaller than or equal to 255.'); } @@ -602,6 +722,9 @@ public function getTestMode() */ public function setTestMode(?bool $test_mode) { + if (is_null($test_mode)) { + throw new InvalidArgumentException('non-nullable test_mode cannot be null'); + } $this->container['test_mode'] = $test_mode; return $this; @@ -626,7 +749,10 @@ public function getTitle() */ public function setTitle(?string $title) { - if (!is_null($title) && (mb_strlen($title) > 255)) { + if (is_null($title)) { + throw new InvalidArgumentException('non-nullable title cannot be null'); + } + if (mb_strlen($title) > 255) { throw new InvalidArgumentException('invalid length for $title when calling SignatureRequestBulkSendWithTemplateRequest., must be smaller than or equal to 255.'); } @@ -638,12 +764,10 @@ public function setTitle(?string $title) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -651,7 +775,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -664,13 +788,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -682,12 +804,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -696,8 +816,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SignatureRequestCreateEmbeddedRequest.php b/sdks/php/src/Model/SignatureRequestCreateEmbeddedRequest.php index 0f7456177..7d14b823c 100644 --- a/sdks/php/src/Model/SignatureRequestCreateEmbeddedRequest.php +++ b/sdks/php/src/Model/SignatureRequestCreateEmbeddedRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -39,11 +38,8 @@ * SignatureRequestCreateEmbeddedRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SignatureRequestCreateEmbeddedRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -122,6 +118,45 @@ class SignatureRequestCreateEmbeddedRequest implements ModelInterface, ArrayAcce 'expires_at' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'client_id' => false, + 'files' => false, + 'file_urls' => false, + 'signers' => false, + 'grouped_signers' => false, + 'allow_decline' => false, + 'allow_reassign' => false, + 'attachments' => false, + 'cc_email_addresses' => false, + 'custom_fields' => false, + 'field_options' => false, + 'form_field_groups' => false, + 'form_field_rules' => false, + 'form_fields_per_document' => false, + 'hide_text_tags' => false, + 'message' => false, + 'metadata' => false, + 'signing_options' => false, + 'subject' => false, + 'test_mode' => false, + 'title' => false, + 'use_text_tags' => false, + 'populate_auto_fill_fields' => false, + 'expires_at' => true, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -142,6 +177,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -283,60 +362,78 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['client_id'] = $data['client_id'] ?? null; - $this->container['files'] = $data['files'] ?? null; - $this->container['file_urls'] = $data['file_urls'] ?? null; - $this->container['signers'] = $data['signers'] ?? null; - $this->container['grouped_signers'] = $data['grouped_signers'] ?? null; - $this->container['allow_decline'] = $data['allow_decline'] ?? false; - $this->container['allow_reassign'] = $data['allow_reassign'] ?? false; - $this->container['attachments'] = $data['attachments'] ?? null; - $this->container['cc_email_addresses'] = $data['cc_email_addresses'] ?? null; - $this->container['custom_fields'] = $data['custom_fields'] ?? null; - $this->container['field_options'] = $data['field_options'] ?? null; - $this->container['form_field_groups'] = $data['form_field_groups'] ?? null; - $this->container['form_field_rules'] = $data['form_field_rules'] ?? null; - $this->container['form_fields_per_document'] = $data['form_fields_per_document'] ?? null; - $this->container['hide_text_tags'] = $data['hide_text_tags'] ?? false; - $this->container['message'] = $data['message'] ?? null; - $this->container['metadata'] = $data['metadata'] ?? null; - $this->container['signing_options'] = $data['signing_options'] ?? null; - $this->container['subject'] = $data['subject'] ?? null; - $this->container['test_mode'] = $data['test_mode'] ?? false; - $this->container['title'] = $data['title'] ?? null; - $this->container['use_text_tags'] = $data['use_text_tags'] ?? false; - $this->container['populate_auto_fill_fields'] = $data['populate_auto_fill_fields'] ?? false; - $this->container['expires_at'] = $data['expires_at'] ?? null; - } - - /** @deprecated use ::init() */ + $this->setIfExists('client_id', $data ?? [], null); + $this->setIfExists('files', $data ?? [], null); + $this->setIfExists('file_urls', $data ?? [], null); + $this->setIfExists('signers', $data ?? [], null); + $this->setIfExists('grouped_signers', $data ?? [], null); + $this->setIfExists('allow_decline', $data ?? [], false); + $this->setIfExists('allow_reassign', $data ?? [], false); + $this->setIfExists('attachments', $data ?? [], null); + $this->setIfExists('cc_email_addresses', $data ?? [], null); + $this->setIfExists('custom_fields', $data ?? [], null); + $this->setIfExists('field_options', $data ?? [], null); + $this->setIfExists('form_field_groups', $data ?? [], null); + $this->setIfExists('form_field_rules', $data ?? [], null); + $this->setIfExists('form_fields_per_document', $data ?? [], null); + $this->setIfExists('hide_text_tags', $data ?? [], false); + $this->setIfExists('message', $data ?? [], null); + $this->setIfExists('metadata', $data ?? [], null); + $this->setIfExists('signing_options', $data ?? [], null); + $this->setIfExists('subject', $data ?? [], null); + $this->setIfExists('test_mode', $data ?? [], false); + $this->setIfExists('title', $data ?? [], null); + $this->setIfExists('use_text_tags', $data ?? [], false); + $this->setIfExists('populate_auto_fill_fields', $data ?? [], false); + $this->setIfExists('expires_at', $data ?? [], null); + } + + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SignatureRequestCreateEmbeddedRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SignatureRequestCreateEmbeddedRequest { - /** @var SignatureRequestCreateEmbeddedRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SignatureRequestCreateEmbeddedRequest */ + return ObjectSerializer::deserialize( $data, SignatureRequestCreateEmbeddedRequest::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -396,6 +493,9 @@ public function getClientId() */ public function setClientId(string $client_id) { + if (is_null($client_id)) { + throw new InvalidArgumentException('non-nullable client_id cannot be null'); + } $this->container['client_id'] = $client_id; return $this; @@ -420,6 +520,9 @@ public function getFiles() */ public function setFiles(?array $files) { + if (is_null($files)) { + throw new InvalidArgumentException('non-nullable files cannot be null'); + } $this->container['files'] = $files; return $this; @@ -444,6 +547,9 @@ public function getFileUrls() */ public function setFileUrls(?array $file_urls) { + if (is_null($file_urls)) { + throw new InvalidArgumentException('non-nullable file_urls cannot be null'); + } $this->container['file_urls'] = $file_urls; return $this; @@ -468,6 +574,9 @@ public function getSigners() */ public function setSigners(?array $signers) { + if (is_null($signers)) { + throw new InvalidArgumentException('non-nullable signers cannot be null'); + } $this->container['signers'] = $signers; return $this; @@ -492,6 +601,9 @@ public function getGroupedSigners() */ public function setGroupedSigners(?array $grouped_signers) { + if (is_null($grouped_signers)) { + throw new InvalidArgumentException('non-nullable grouped_signers cannot be null'); + } $this->container['grouped_signers'] = $grouped_signers; return $this; @@ -516,6 +628,9 @@ public function getAllowDecline() */ public function setAllowDecline(?bool $allow_decline) { + if (is_null($allow_decline)) { + throw new InvalidArgumentException('non-nullable allow_decline cannot be null'); + } $this->container['allow_decline'] = $allow_decline; return $this; @@ -540,6 +655,9 @@ public function getAllowReassign() */ public function setAllowReassign(?bool $allow_reassign) { + if (is_null($allow_reassign)) { + throw new InvalidArgumentException('non-nullable allow_reassign cannot be null'); + } $this->container['allow_reassign'] = $allow_reassign; return $this; @@ -564,6 +682,9 @@ public function getAttachments() */ public function setAttachments(?array $attachments) { + if (is_null($attachments)) { + throw new InvalidArgumentException('non-nullable attachments cannot be null'); + } $this->container['attachments'] = $attachments; return $this; @@ -588,6 +709,9 @@ public function getCcEmailAddresses() */ public function setCcEmailAddresses(?array $cc_email_addresses) { + if (is_null($cc_email_addresses)) { + throw new InvalidArgumentException('non-nullable cc_email_addresses cannot be null'); + } $this->container['cc_email_addresses'] = $cc_email_addresses; return $this; @@ -612,6 +736,9 @@ public function getCustomFields() */ public function setCustomFields(?array $custom_fields) { + if (is_null($custom_fields)) { + throw new InvalidArgumentException('non-nullable custom_fields cannot be null'); + } $this->container['custom_fields'] = $custom_fields; return $this; @@ -636,6 +763,9 @@ public function getFieldOptions() */ public function setFieldOptions(?SubFieldOptions $field_options) { + if (is_null($field_options)) { + throw new InvalidArgumentException('non-nullable field_options cannot be null'); + } $this->container['field_options'] = $field_options; return $this; @@ -660,6 +790,9 @@ public function getFormFieldGroups() */ public function setFormFieldGroups(?array $form_field_groups) { + if (is_null($form_field_groups)) { + throw new InvalidArgumentException('non-nullable form_field_groups cannot be null'); + } $this->container['form_field_groups'] = $form_field_groups; return $this; @@ -684,6 +817,9 @@ public function getFormFieldRules() */ public function setFormFieldRules(?array $form_field_rules) { + if (is_null($form_field_rules)) { + throw new InvalidArgumentException('non-nullable form_field_rules cannot be null'); + } $this->container['form_field_rules'] = $form_field_rules; return $this; @@ -708,6 +844,9 @@ public function getFormFieldsPerDocument() */ public function setFormFieldsPerDocument(?array $form_fields_per_document) { + if (is_null($form_fields_per_document)) { + throw new InvalidArgumentException('non-nullable form_fields_per_document cannot be null'); + } $this->container['form_fields_per_document'] = $form_fields_per_document; return $this; @@ -732,6 +871,9 @@ public function getHideTextTags() */ public function setHideTextTags(?bool $hide_text_tags) { + if (is_null($hide_text_tags)) { + throw new InvalidArgumentException('non-nullable hide_text_tags cannot be null'); + } $this->container['hide_text_tags'] = $hide_text_tags; return $this; @@ -756,7 +898,10 @@ public function getMessage() */ public function setMessage(?string $message) { - if (!is_null($message) && (mb_strlen($message) > 5000)) { + if (is_null($message)) { + throw new InvalidArgumentException('non-nullable message cannot be null'); + } + if (mb_strlen($message) > 5000) { throw new InvalidArgumentException('invalid length for $message when calling SignatureRequestCreateEmbeddedRequest., must be smaller than or equal to 5000.'); } @@ -784,6 +929,10 @@ public function getMetadata() */ public function setMetadata(?array $metadata) { + if (is_null($metadata)) { + throw new InvalidArgumentException('non-nullable metadata cannot be null'); + } + $this->container['metadata'] = $metadata; return $this; @@ -808,6 +957,9 @@ public function getSigningOptions() */ public function setSigningOptions(?SubSigningOptions $signing_options) { + if (is_null($signing_options)) { + throw new InvalidArgumentException('non-nullable signing_options cannot be null'); + } $this->container['signing_options'] = $signing_options; return $this; @@ -832,7 +984,10 @@ public function getSubject() */ public function setSubject(?string $subject) { - if (!is_null($subject) && (mb_strlen($subject) > 255)) { + if (is_null($subject)) { + throw new InvalidArgumentException('non-nullable subject cannot be null'); + } + if (mb_strlen($subject) > 255) { throw new InvalidArgumentException('invalid length for $subject when calling SignatureRequestCreateEmbeddedRequest., must be smaller than or equal to 255.'); } @@ -860,6 +1015,9 @@ public function getTestMode() */ public function setTestMode(?bool $test_mode) { + if (is_null($test_mode)) { + throw new InvalidArgumentException('non-nullable test_mode cannot be null'); + } $this->container['test_mode'] = $test_mode; return $this; @@ -884,7 +1042,10 @@ public function getTitle() */ public function setTitle(?string $title) { - if (!is_null($title) && (mb_strlen($title) > 255)) { + if (is_null($title)) { + throw new InvalidArgumentException('non-nullable title cannot be null'); + } + if (mb_strlen($title) > 255) { throw new InvalidArgumentException('invalid length for $title when calling SignatureRequestCreateEmbeddedRequest., must be smaller than or equal to 255.'); } @@ -912,6 +1073,9 @@ public function getUseTextTags() */ public function setUseTextTags(?bool $use_text_tags) { + if (is_null($use_text_tags)) { + throw new InvalidArgumentException('non-nullable use_text_tags cannot be null'); + } $this->container['use_text_tags'] = $use_text_tags; return $this; @@ -936,6 +1100,9 @@ public function getPopulateAutoFillFields() */ public function setPopulateAutoFillFields(?bool $populate_auto_fill_fields) { + if (is_null($populate_auto_fill_fields)) { + throw new InvalidArgumentException('non-nullable populate_auto_fill_fields cannot be null'); + } $this->container['populate_auto_fill_fields'] = $populate_auto_fill_fields; return $this; @@ -960,6 +1127,16 @@ public function getExpiresAt() */ public function setExpiresAt(?int $expires_at) { + if (is_null($expires_at)) { + array_push($this->openAPINullablesSetToNull, 'expires_at'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('expires_at', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['expires_at'] = $expires_at; return $this; @@ -968,12 +1145,10 @@ public function setExpiresAt(?int $expires_at) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -981,7 +1156,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -994,13 +1169,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -1012,12 +1185,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -1026,8 +1197,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SignatureRequestCreateEmbeddedWithTemplateRequest.php b/sdks/php/src/Model/SignatureRequestCreateEmbeddedWithTemplateRequest.php index 5a9d50c4c..b98f7b8b7 100644 --- a/sdks/php/src/Model/SignatureRequestCreateEmbeddedWithTemplateRequest.php +++ b/sdks/php/src/Model/SignatureRequestCreateEmbeddedWithTemplateRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -39,11 +38,8 @@ * SignatureRequestCreateEmbeddedWithTemplateRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SignatureRequestCreateEmbeddedWithTemplateRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -104,6 +100,36 @@ class SignatureRequestCreateEmbeddedWithTemplateRequest implements ModelInterfac 'populate_auto_fill_fields' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'template_ids' => false, + 'client_id' => false, + 'signers' => false, + 'allow_decline' => false, + 'ccs' => false, + 'custom_fields' => false, + 'files' => false, + 'file_urls' => false, + 'message' => false, + 'metadata' => false, + 'signing_options' => false, + 'subject' => false, + 'test_mode' => false, + 'title' => false, + 'populate_auto_fill_fields' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -124,6 +150,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -238,51 +308,69 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['template_ids'] = $data['template_ids'] ?? null; - $this->container['client_id'] = $data['client_id'] ?? null; - $this->container['signers'] = $data['signers'] ?? null; - $this->container['allow_decline'] = $data['allow_decline'] ?? false; - $this->container['ccs'] = $data['ccs'] ?? null; - $this->container['custom_fields'] = $data['custom_fields'] ?? null; - $this->container['files'] = $data['files'] ?? null; - $this->container['file_urls'] = $data['file_urls'] ?? null; - $this->container['message'] = $data['message'] ?? null; - $this->container['metadata'] = $data['metadata'] ?? null; - $this->container['signing_options'] = $data['signing_options'] ?? null; - $this->container['subject'] = $data['subject'] ?? null; - $this->container['test_mode'] = $data['test_mode'] ?? false; - $this->container['title'] = $data['title'] ?? null; - $this->container['populate_auto_fill_fields'] = $data['populate_auto_fill_fields'] ?? false; - } - - /** @deprecated use ::init() */ + $this->setIfExists('template_ids', $data ?? [], null); + $this->setIfExists('client_id', $data ?? [], null); + $this->setIfExists('signers', $data ?? [], null); + $this->setIfExists('allow_decline', $data ?? [], false); + $this->setIfExists('ccs', $data ?? [], null); + $this->setIfExists('custom_fields', $data ?? [], null); + $this->setIfExists('files', $data ?? [], null); + $this->setIfExists('file_urls', $data ?? [], null); + $this->setIfExists('message', $data ?? [], null); + $this->setIfExists('metadata', $data ?? [], null); + $this->setIfExists('signing_options', $data ?? [], null); + $this->setIfExists('subject', $data ?? [], null); + $this->setIfExists('test_mode', $data ?? [], false); + $this->setIfExists('title', $data ?? [], null); + $this->setIfExists('populate_auto_fill_fields', $data ?? [], false); + } + + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SignatureRequestCreateEmbeddedWithTemplateRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SignatureRequestCreateEmbeddedWithTemplateRequest { - /** @var SignatureRequestCreateEmbeddedWithTemplateRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SignatureRequestCreateEmbeddedWithTemplateRequest */ + return ObjectSerializer::deserialize( $data, SignatureRequestCreateEmbeddedWithTemplateRequest::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -348,6 +436,9 @@ public function getTemplateIds() */ public function setTemplateIds(array $template_ids) { + if (is_null($template_ids)) { + throw new InvalidArgumentException('non-nullable template_ids cannot be null'); + } $this->container['template_ids'] = $template_ids; return $this; @@ -372,6 +463,9 @@ public function getClientId() */ public function setClientId(string $client_id) { + if (is_null($client_id)) { + throw new InvalidArgumentException('non-nullable client_id cannot be null'); + } $this->container['client_id'] = $client_id; return $this; @@ -396,6 +490,9 @@ public function getSigners() */ public function setSigners(array $signers) { + if (is_null($signers)) { + throw new InvalidArgumentException('non-nullable signers cannot be null'); + } $this->container['signers'] = $signers; return $this; @@ -420,6 +517,9 @@ public function getAllowDecline() */ public function setAllowDecline(?bool $allow_decline) { + if (is_null($allow_decline)) { + throw new InvalidArgumentException('non-nullable allow_decline cannot be null'); + } $this->container['allow_decline'] = $allow_decline; return $this; @@ -444,6 +544,9 @@ public function getCcs() */ public function setCcs(?array $ccs) { + if (is_null($ccs)) { + throw new InvalidArgumentException('non-nullable ccs cannot be null'); + } $this->container['ccs'] = $ccs; return $this; @@ -468,6 +571,9 @@ public function getCustomFields() */ public function setCustomFields(?array $custom_fields) { + if (is_null($custom_fields)) { + throw new InvalidArgumentException('non-nullable custom_fields cannot be null'); + } $this->container['custom_fields'] = $custom_fields; return $this; @@ -492,6 +598,9 @@ public function getFiles() */ public function setFiles(?array $files) { + if (is_null($files)) { + throw new InvalidArgumentException('non-nullable files cannot be null'); + } $this->container['files'] = $files; return $this; @@ -516,6 +625,9 @@ public function getFileUrls() */ public function setFileUrls(?array $file_urls) { + if (is_null($file_urls)) { + throw new InvalidArgumentException('non-nullable file_urls cannot be null'); + } $this->container['file_urls'] = $file_urls; return $this; @@ -540,7 +652,10 @@ public function getMessage() */ public function setMessage(?string $message) { - if (!is_null($message) && (mb_strlen($message) > 5000)) { + if (is_null($message)) { + throw new InvalidArgumentException('non-nullable message cannot be null'); + } + if (mb_strlen($message) > 5000) { throw new InvalidArgumentException('invalid length for $message when calling SignatureRequestCreateEmbeddedWithTemplateRequest., must be smaller than or equal to 5000.'); } @@ -568,6 +683,10 @@ public function getMetadata() */ public function setMetadata(?array $metadata) { + if (is_null($metadata)) { + throw new InvalidArgumentException('non-nullable metadata cannot be null'); + } + $this->container['metadata'] = $metadata; return $this; @@ -592,6 +711,9 @@ public function getSigningOptions() */ public function setSigningOptions(?SubSigningOptions $signing_options) { + if (is_null($signing_options)) { + throw new InvalidArgumentException('non-nullable signing_options cannot be null'); + } $this->container['signing_options'] = $signing_options; return $this; @@ -616,7 +738,10 @@ public function getSubject() */ public function setSubject(?string $subject) { - if (!is_null($subject) && (mb_strlen($subject) > 255)) { + if (is_null($subject)) { + throw new InvalidArgumentException('non-nullable subject cannot be null'); + } + if (mb_strlen($subject) > 255) { throw new InvalidArgumentException('invalid length for $subject when calling SignatureRequestCreateEmbeddedWithTemplateRequest., must be smaller than or equal to 255.'); } @@ -644,6 +769,9 @@ public function getTestMode() */ public function setTestMode(?bool $test_mode) { + if (is_null($test_mode)) { + throw new InvalidArgumentException('non-nullable test_mode cannot be null'); + } $this->container['test_mode'] = $test_mode; return $this; @@ -668,7 +796,10 @@ public function getTitle() */ public function setTitle(?string $title) { - if (!is_null($title) && (mb_strlen($title) > 255)) { + if (is_null($title)) { + throw new InvalidArgumentException('non-nullable title cannot be null'); + } + if (mb_strlen($title) > 255) { throw new InvalidArgumentException('invalid length for $title when calling SignatureRequestCreateEmbeddedWithTemplateRequest., must be smaller than or equal to 255.'); } @@ -696,6 +827,9 @@ public function getPopulateAutoFillFields() */ public function setPopulateAutoFillFields(?bool $populate_auto_fill_fields) { + if (is_null($populate_auto_fill_fields)) { + throw new InvalidArgumentException('non-nullable populate_auto_fill_fields cannot be null'); + } $this->container['populate_auto_fill_fields'] = $populate_auto_fill_fields; return $this; @@ -704,12 +838,10 @@ public function setPopulateAutoFillFields(?bool $populate_auto_fill_fields) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -717,7 +849,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -730,13 +862,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -748,12 +878,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -762,8 +890,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SignatureRequestGetResponse.php b/sdks/php/src/Model/SignatureRequestGetResponse.php index 607e3b2bb..e3c2ea574 100644 --- a/sdks/php/src/Model/SignatureRequestGetResponse.php +++ b/sdks/php/src/Model/SignatureRequestGetResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * SignatureRequestGetResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class SignatureRequestGetResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -77,6 +73,23 @@ class SignatureRequestGetResponse implements ModelInterface, ArrayAccess, JsonSe 'warnings' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'signature_request' => false, + 'warnings' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -97,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -172,38 +229,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['signature_request'] = $data['signature_request'] ?? null; - $this->container['warnings'] = $data['warnings'] ?? null; + $this->setIfExists('signature_request', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SignatureRequestGetResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SignatureRequestGetResponse { - /** @var SignatureRequestGetResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SignatureRequestGetResponse */ + return ObjectSerializer::deserialize( $data, SignatureRequestGetResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -213,9 +288,7 @@ public static function init(array $data): SignatureRequestGetResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -248,6 +321,9 @@ public function getSignatureRequest() */ public function setSignatureRequest(?SignatureRequestResponse $signature_request) { + if (is_null($signature_request)) { + throw new InvalidArgumentException('non-nullable signature_request cannot be null'); + } $this->container['signature_request'] = $signature_request; return $this; @@ -272,6 +348,9 @@ public function getWarnings() */ public function setWarnings(?array $warnings) { + if (is_null($warnings)) { + throw new InvalidArgumentException('non-nullable warnings cannot be null'); + } $this->container['warnings'] = $warnings; return $this; @@ -280,12 +359,10 @@ public function setWarnings(?array $warnings) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -293,7 +370,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -306,13 +383,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -324,12 +399,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -338,8 +411,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SignatureRequestListResponse.php b/sdks/php/src/Model/SignatureRequestListResponse.php index 0152544e9..36a043891 100644 --- a/sdks/php/src/Model/SignatureRequestListResponse.php +++ b/sdks/php/src/Model/SignatureRequestListResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * SignatureRequestListResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class SignatureRequestListResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -79,6 +75,24 @@ class SignatureRequestListResponse implements ModelInterface, ArrayAccess, JsonS 'warnings' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'signature_requests' => false, + 'list_info' => false, + 'warnings' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -99,6 +113,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -177,39 +235,57 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['signature_requests'] = $data['signature_requests'] ?? null; - $this->container['list_info'] = $data['list_info'] ?? null; - $this->container['warnings'] = $data['warnings'] ?? null; + $this->setIfExists('signature_requests', $data ?? [], null); + $this->setIfExists('list_info', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SignatureRequestListResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SignatureRequestListResponse { - /** @var SignatureRequestListResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SignatureRequestListResponse */ + return ObjectSerializer::deserialize( $data, SignatureRequestListResponse::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -219,9 +295,7 @@ public static function init(array $data): SignatureRequestListResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -254,6 +328,9 @@ public function getSignatureRequests() */ public function setSignatureRequests(?array $signature_requests) { + if (is_null($signature_requests)) { + throw new InvalidArgumentException('non-nullable signature_requests cannot be null'); + } $this->container['signature_requests'] = $signature_requests; return $this; @@ -278,6 +355,9 @@ public function getListInfo() */ public function setListInfo(?ListInfoResponse $list_info) { + if (is_null($list_info)) { + throw new InvalidArgumentException('non-nullable list_info cannot be null'); + } $this->container['list_info'] = $list_info; return $this; @@ -302,6 +382,9 @@ public function getWarnings() */ public function setWarnings(?array $warnings) { + if (is_null($warnings)) { + throw new InvalidArgumentException('non-nullable warnings cannot be null'); + } $this->container['warnings'] = $warnings; return $this; @@ -310,12 +393,10 @@ public function setWarnings(?array $warnings) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -323,7 +404,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -336,13 +417,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -354,12 +433,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -368,8 +445,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SignatureRequestRemindRequest.php b/sdks/php/src/Model/SignatureRequestRemindRequest.php index 3ebd94f21..5662351ef 100644 --- a/sdks/php/src/Model/SignatureRequestRemindRequest.php +++ b/sdks/php/src/Model/SignatureRequestRemindRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * SignatureRequestRemindRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SignatureRequestRemindRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -76,6 +73,23 @@ class SignatureRequestRemindRequest implements ModelInterface, ArrayAccess, Json 'name' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'email_address' => false, + 'name' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -96,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -171,38 +229,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['email_address'] = $data['email_address'] ?? null; - $this->container['name'] = $data['name'] ?? null; + $this->setIfExists('email_address', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SignatureRequestRemindRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SignatureRequestRemindRequest { - /** @var SignatureRequestRemindRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SignatureRequestRemindRequest */ + return ObjectSerializer::deserialize( $data, SignatureRequestRemindRequest::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -217,7 +293,6 @@ public function listInvalidProperties() if ($this->container['email_address'] === null) { $invalidProperties[] = "'email_address' can't be null"; } - return $invalidProperties; } @@ -251,6 +326,9 @@ public function getEmailAddress() */ public function setEmailAddress(string $email_address) { + if (is_null($email_address)) { + throw new InvalidArgumentException('non-nullable email_address cannot be null'); + } $this->container['email_address'] = $email_address; return $this; @@ -275,6 +353,9 @@ public function getName() */ public function setName(?string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -283,12 +364,10 @@ public function setName(?string $name) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -296,7 +375,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -309,13 +388,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -327,12 +404,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -341,8 +416,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SignatureRequestResponse.php b/sdks/php/src/Model/SignatureRequestResponse.php index 9a49a3cc3..14386d427 100644 --- a/sdks/php/src/Model/SignatureRequestResponse.php +++ b/sdks/php/src/Model/SignatureRequestResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,12 +38,8 @@ * * @category Class * @description Contains information about a signature request. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class SignatureRequestResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -124,6 +120,46 @@ class SignatureRequestResponse implements ModelInterface, ArrayAccess, JsonSeria 'bulk_send_job_id' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'test_mode' => true, + 'signature_request_id' => false, + 'requester_email_address' => false, + 'title' => false, + 'original_title' => false, + 'subject' => true, + 'message' => true, + 'metadata' => false, + 'created_at' => false, + 'expires_at' => false, + 'is_complete' => false, + 'is_declined' => false, + 'has_error' => false, + 'files_url' => false, + 'signing_url' => true, + 'details_url' => false, + 'cc_email_addresses' => false, + 'signing_redirect_url' => true, + 'final_copy_uri' => true, + 'template_ids' => true, + 'custom_fields' => true, + 'attachments' => true, + 'response_data' => true, + 'signatures' => false, + 'bulk_send_job_id' => true, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -144,6 +180,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -288,61 +368,79 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['test_mode'] = $data['test_mode'] ?? false; - $this->container['signature_request_id'] = $data['signature_request_id'] ?? null; - $this->container['requester_email_address'] = $data['requester_email_address'] ?? null; - $this->container['title'] = $data['title'] ?? null; - $this->container['original_title'] = $data['original_title'] ?? null; - $this->container['subject'] = $data['subject'] ?? null; - $this->container['message'] = $data['message'] ?? null; - $this->container['metadata'] = $data['metadata'] ?? null; - $this->container['created_at'] = $data['created_at'] ?? null; - $this->container['expires_at'] = $data['expires_at'] ?? null; - $this->container['is_complete'] = $data['is_complete'] ?? null; - $this->container['is_declined'] = $data['is_declined'] ?? null; - $this->container['has_error'] = $data['has_error'] ?? null; - $this->container['files_url'] = $data['files_url'] ?? null; - $this->container['signing_url'] = $data['signing_url'] ?? null; - $this->container['details_url'] = $data['details_url'] ?? null; - $this->container['cc_email_addresses'] = $data['cc_email_addresses'] ?? null; - $this->container['signing_redirect_url'] = $data['signing_redirect_url'] ?? null; - $this->container['final_copy_uri'] = $data['final_copy_uri'] ?? null; - $this->container['template_ids'] = $data['template_ids'] ?? null; - $this->container['custom_fields'] = $data['custom_fields'] ?? null; - $this->container['attachments'] = $data['attachments'] ?? null; - $this->container['response_data'] = $data['response_data'] ?? null; - $this->container['signatures'] = $data['signatures'] ?? null; - $this->container['bulk_send_job_id'] = $data['bulk_send_job_id'] ?? null; - } - - /** @deprecated use ::init() */ + $this->setIfExists('test_mode', $data ?? [], false); + $this->setIfExists('signature_request_id', $data ?? [], null); + $this->setIfExists('requester_email_address', $data ?? [], null); + $this->setIfExists('title', $data ?? [], null); + $this->setIfExists('original_title', $data ?? [], null); + $this->setIfExists('subject', $data ?? [], null); + $this->setIfExists('message', $data ?? [], null); + $this->setIfExists('metadata', $data ?? [], null); + $this->setIfExists('created_at', $data ?? [], null); + $this->setIfExists('expires_at', $data ?? [], null); + $this->setIfExists('is_complete', $data ?? [], null); + $this->setIfExists('is_declined', $data ?? [], null); + $this->setIfExists('has_error', $data ?? [], null); + $this->setIfExists('files_url', $data ?? [], null); + $this->setIfExists('signing_url', $data ?? [], null); + $this->setIfExists('details_url', $data ?? [], null); + $this->setIfExists('cc_email_addresses', $data ?? [], null); + $this->setIfExists('signing_redirect_url', $data ?? [], null); + $this->setIfExists('final_copy_uri', $data ?? [], null); + $this->setIfExists('template_ids', $data ?? [], null); + $this->setIfExists('custom_fields', $data ?? [], null); + $this->setIfExists('attachments', $data ?? [], null); + $this->setIfExists('response_data', $data ?? [], null); + $this->setIfExists('signatures', $data ?? [], null); + $this->setIfExists('bulk_send_job_id', $data ?? [], null); + } + + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SignatureRequestResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SignatureRequestResponse { - /** @var SignatureRequestResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SignatureRequestResponse */ + return ObjectSerializer::deserialize( $data, SignatureRequestResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -352,9 +450,7 @@ public static function init(array $data): SignatureRequestResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -387,6 +483,16 @@ public function getTestMode() */ public function setTestMode(?bool $test_mode) { + if (is_null($test_mode)) { + array_push($this->openAPINullablesSetToNull, 'test_mode'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('test_mode', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['test_mode'] = $test_mode; return $this; @@ -411,6 +517,9 @@ public function getSignatureRequestId() */ public function setSignatureRequestId(?string $signature_request_id) { + if (is_null($signature_request_id)) { + throw new InvalidArgumentException('non-nullable signature_request_id cannot be null'); + } $this->container['signature_request_id'] = $signature_request_id; return $this; @@ -435,6 +544,9 @@ public function getRequesterEmailAddress() */ public function setRequesterEmailAddress(?string $requester_email_address) { + if (is_null($requester_email_address)) { + throw new InvalidArgumentException('non-nullable requester_email_address cannot be null'); + } $this->container['requester_email_address'] = $requester_email_address; return $this; @@ -459,6 +571,9 @@ public function getTitle() */ public function setTitle(?string $title) { + if (is_null($title)) { + throw new InvalidArgumentException('non-nullable title cannot be null'); + } $this->container['title'] = $title; return $this; @@ -483,6 +598,9 @@ public function getOriginalTitle() */ public function setOriginalTitle(?string $original_title) { + if (is_null($original_title)) { + throw new InvalidArgumentException('non-nullable original_title cannot be null'); + } $this->container['original_title'] = $original_title; return $this; @@ -507,6 +625,16 @@ public function getSubject() */ public function setSubject(?string $subject) { + if (is_null($subject)) { + array_push($this->openAPINullablesSetToNull, 'subject'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('subject', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['subject'] = $subject; return $this; @@ -531,6 +659,16 @@ public function getMessage() */ public function setMessage(?string $message) { + if (is_null($message)) { + array_push($this->openAPINullablesSetToNull, 'message'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('message', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['message'] = $message; return $this; @@ -555,6 +693,9 @@ public function getMetadata() */ public function setMetadata(?array $metadata) { + if (is_null($metadata)) { + throw new InvalidArgumentException('non-nullable metadata cannot be null'); + } $this->container['metadata'] = $metadata; return $this; @@ -579,6 +720,9 @@ public function getCreatedAt() */ public function setCreatedAt(?int $created_at) { + if (is_null($created_at)) { + throw new InvalidArgumentException('non-nullable created_at cannot be null'); + } $this->container['created_at'] = $created_at; return $this; @@ -603,6 +747,9 @@ public function getExpiresAt() */ public function setExpiresAt(?int $expires_at) { + if (is_null($expires_at)) { + throw new InvalidArgumentException('non-nullable expires_at cannot be null'); + } $this->container['expires_at'] = $expires_at; return $this; @@ -627,6 +774,9 @@ public function getIsComplete() */ public function setIsComplete(?bool $is_complete) { + if (is_null($is_complete)) { + throw new InvalidArgumentException('non-nullable is_complete cannot be null'); + } $this->container['is_complete'] = $is_complete; return $this; @@ -651,6 +801,9 @@ public function getIsDeclined() */ public function setIsDeclined(?bool $is_declined) { + if (is_null($is_declined)) { + throw new InvalidArgumentException('non-nullable is_declined cannot be null'); + } $this->container['is_declined'] = $is_declined; return $this; @@ -675,6 +828,9 @@ public function getHasError() */ public function setHasError(?bool $has_error) { + if (is_null($has_error)) { + throw new InvalidArgumentException('non-nullable has_error cannot be null'); + } $this->container['has_error'] = $has_error; return $this; @@ -699,6 +855,9 @@ public function getFilesUrl() */ public function setFilesUrl(?string $files_url) { + if (is_null($files_url)) { + throw new InvalidArgumentException('non-nullable files_url cannot be null'); + } $this->container['files_url'] = $files_url; return $this; @@ -723,6 +882,16 @@ public function getSigningUrl() */ public function setSigningUrl(?string $signing_url) { + if (is_null($signing_url)) { + array_push($this->openAPINullablesSetToNull, 'signing_url'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('signing_url', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['signing_url'] = $signing_url; return $this; @@ -747,6 +916,9 @@ public function getDetailsUrl() */ public function setDetailsUrl(?string $details_url) { + if (is_null($details_url)) { + throw new InvalidArgumentException('non-nullable details_url cannot be null'); + } $this->container['details_url'] = $details_url; return $this; @@ -771,6 +943,9 @@ public function getCcEmailAddresses() */ public function setCcEmailAddresses(?array $cc_email_addresses) { + if (is_null($cc_email_addresses)) { + throw new InvalidArgumentException('non-nullable cc_email_addresses cannot be null'); + } $this->container['cc_email_addresses'] = $cc_email_addresses; return $this; @@ -795,6 +970,16 @@ public function getSigningRedirectUrl() */ public function setSigningRedirectUrl(?string $signing_redirect_url) { + if (is_null($signing_redirect_url)) { + array_push($this->openAPINullablesSetToNull, 'signing_redirect_url'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('signing_redirect_url', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['signing_redirect_url'] = $signing_redirect_url; return $this; @@ -819,6 +1004,16 @@ public function getFinalCopyUri() */ public function setFinalCopyUri(?string $final_copy_uri) { + if (is_null($final_copy_uri)) { + array_push($this->openAPINullablesSetToNull, 'final_copy_uri'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('final_copy_uri', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['final_copy_uri'] = $final_copy_uri; return $this; @@ -843,6 +1038,16 @@ public function getTemplateIds() */ public function setTemplateIds(?array $template_ids) { + if (is_null($template_ids)) { + array_push($this->openAPINullablesSetToNull, 'template_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('template_ids', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['template_ids'] = $template_ids; return $this; @@ -867,6 +1072,16 @@ public function getCustomFields() */ public function setCustomFields(?array $custom_fields) { + if (is_null($custom_fields)) { + array_push($this->openAPINullablesSetToNull, 'custom_fields'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('custom_fields', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['custom_fields'] = $custom_fields; return $this; @@ -891,6 +1106,16 @@ public function getAttachments() */ public function setAttachments(?array $attachments) { + if (is_null($attachments)) { + array_push($this->openAPINullablesSetToNull, 'attachments'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('attachments', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['attachments'] = $attachments; return $this; @@ -915,6 +1140,16 @@ public function getResponseData() */ public function setResponseData(?array $response_data) { + if (is_null($response_data)) { + array_push($this->openAPINullablesSetToNull, 'response_data'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('response_data', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['response_data'] = $response_data; return $this; @@ -939,6 +1174,9 @@ public function getSignatures() */ public function setSignatures(?array $signatures) { + if (is_null($signatures)) { + throw new InvalidArgumentException('non-nullable signatures cannot be null'); + } $this->container['signatures'] = $signatures; return $this; @@ -963,6 +1201,16 @@ public function getBulkSendJobId() */ public function setBulkSendJobId(?string $bulk_send_job_id) { + if (is_null($bulk_send_job_id)) { + array_push($this->openAPINullablesSetToNull, 'bulk_send_job_id'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('bulk_send_job_id', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['bulk_send_job_id'] = $bulk_send_job_id; return $this; @@ -971,12 +1219,10 @@ public function setBulkSendJobId(?string $bulk_send_job_id) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -984,7 +1230,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -997,13 +1243,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -1015,12 +1259,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -1029,8 +1271,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SignatureRequestResponseAttachment.php b/sdks/php/src/Model/SignatureRequestResponseAttachment.php index c8d34976d..245930a52 100644 --- a/sdks/php/src/Model/SignatureRequestResponseAttachment.php +++ b/sdks/php/src/Model/SignatureRequestResponseAttachment.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,12 +38,8 @@ * * @category Class * @description Signer attachments. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class SignatureRequestResponseAttachment implements ModelInterface, ArrayAccess, JsonSerializable { @@ -86,6 +82,27 @@ class SignatureRequestResponseAttachment implements ModelInterface, ArrayAccess, 'uploaded_at' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'signer' => false, + 'name' => false, + 'required' => false, + 'instructions' => true, + 'uploaded_at' => true, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -106,6 +123,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -193,42 +254,60 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['id'] = $data['id'] ?? null; - $this->container['signer'] = $data['signer'] ?? null; - $this->container['name'] = $data['name'] ?? null; - $this->container['required'] = $data['required'] ?? null; - $this->container['instructions'] = $data['instructions'] ?? null; - $this->container['uploaded_at'] = $data['uploaded_at'] ?? null; + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('signer', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('required', $data ?? [], null); + $this->setIfExists('instructions', $data ?? [], null); + $this->setIfExists('uploaded_at', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SignatureRequestResponseAttachment { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SignatureRequestResponseAttachment { - /** @var SignatureRequestResponseAttachment $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SignatureRequestResponseAttachment */ + return ObjectSerializer::deserialize( $data, SignatureRequestResponseAttachment::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -252,7 +331,6 @@ public function listInvalidProperties() if ($this->container['required'] === null) { $invalidProperties[] = "'required' can't be null"; } - return $invalidProperties; } @@ -286,6 +364,9 @@ public function getId() */ public function setId(string $id) { + if (is_null($id)) { + throw new InvalidArgumentException('non-nullable id cannot be null'); + } $this->container['id'] = $id; return $this; @@ -310,6 +391,9 @@ public function getSigner() */ public function setSigner(string $signer) { + if (is_null($signer)) { + throw new InvalidArgumentException('non-nullable signer cannot be null'); + } $this->container['signer'] = $signer; return $this; @@ -334,6 +418,9 @@ public function getName() */ public function setName(string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -358,6 +445,9 @@ public function getRequired() */ public function setRequired(bool $required) { + if (is_null($required)) { + throw new InvalidArgumentException('non-nullable required cannot be null'); + } $this->container['required'] = $required; return $this; @@ -382,6 +472,16 @@ public function getInstructions() */ public function setInstructions(?string $instructions) { + if (is_null($instructions)) { + array_push($this->openAPINullablesSetToNull, 'instructions'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('instructions', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['instructions'] = $instructions; return $this; @@ -406,6 +506,16 @@ public function getUploadedAt() */ public function setUploadedAt(?int $uploaded_at) { + if (is_null($uploaded_at)) { + array_push($this->openAPINullablesSetToNull, 'uploaded_at'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('uploaded_at', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['uploaded_at'] = $uploaded_at; return $this; @@ -414,12 +524,10 @@ public function setUploadedAt(?int $uploaded_at) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -427,7 +535,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -440,13 +548,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -458,12 +564,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -472,8 +576,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SignatureRequestResponseCustomFieldBase.php b/sdks/php/src/Model/SignatureRequestResponseCustomFieldBase.php index d54d31050..7c1d3a815 100644 --- a/sdks/php/src/Model/SignatureRequestResponseCustomFieldBase.php +++ b/sdks/php/src/Model/SignatureRequestResponseCustomFieldBase.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,14 +38,10 @@ * * @category Class * @description An array of Custom Field objects containing the name and type of each custom field. * Text Field uses `SignatureRequestResponseCustomFieldText` * Checkbox Field uses `SignatureRequestResponseCustomFieldCheckbox` - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ -abstract class SignatureRequestResponseCustomFieldBase implements ModelInterface, ArrayAccess, JsonSerializable +class SignatureRequestResponseCustomFieldBase implements ModelInterface, ArrayAccess, JsonSerializable { public const DISCRIMINATOR = 'type'; @@ -84,6 +80,26 @@ abstract class SignatureRequestResponseCustomFieldBase implements ModelInterface 'editor' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'name' => false, + 'required' => false, + 'api_id' => false, + 'editor' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -104,6 +120,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -188,23 +248,23 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['type'] = $data['type'] ?? null; - $this->container['name'] = $data['name'] ?? null; - $this->container['required'] = $data['required'] ?? null; - $this->container['api_id'] = $data['api_id'] ?? null; - $this->container['editor'] = $data['editor'] ?? null; + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('required', $data ?? [], null); + $this->setIfExists('api_id', $data ?? [], null); + $this->setIfExists('editor', $data ?? [], null); // Initialize discriminator property with the model name. $this->container['type'] = static::$openAPIModelName; @@ -226,6 +286,22 @@ public static function discriminatorClassName(array $data): ?string return null; } + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + /** * Show all the invalid properties with reasons. * @@ -241,7 +317,6 @@ public function listInvalidProperties() if ($this->container['name'] === null) { $invalidProperties[] = "'name' can't be null"; } - return $invalidProperties; } @@ -275,6 +350,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -299,6 +377,9 @@ public function getName() */ public function setName(string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -323,6 +404,9 @@ public function getRequired() */ public function setRequired(?bool $required) { + if (is_null($required)) { + throw new InvalidArgumentException('non-nullable required cannot be null'); + } $this->container['required'] = $required; return $this; @@ -347,6 +431,9 @@ public function getApiId() */ public function setApiId(?string $api_id) { + if (is_null($api_id)) { + throw new InvalidArgumentException('non-nullable api_id cannot be null'); + } $this->container['api_id'] = $api_id; return $this; @@ -371,6 +458,9 @@ public function getEditor() */ public function setEditor(?string $editor) { + if (is_null($editor)) { + throw new InvalidArgumentException('non-nullable editor cannot be null'); + } $this->container['editor'] = $editor; return $this; @@ -379,12 +469,10 @@ public function setEditor(?string $editor) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -392,7 +480,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -405,13 +493,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -423,12 +509,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -437,8 +521,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SignatureRequestResponseCustomFieldCheckbox.php b/sdks/php/src/Model/SignatureRequestResponseCustomFieldCheckbox.php index d6b9a0b16..d16c804e7 100644 --- a/sdks/php/src/Model/SignatureRequestResponseCustomFieldCheckbox.php +++ b/sdks/php/src/Model/SignatureRequestResponseCustomFieldCheckbox.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,6 +28,7 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** @@ -36,11 +36,8 @@ * * @category Class * @description This class extends `SignatureRequestResponseCustomFieldBase`. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SignatureRequestResponseCustomFieldCheckbox extends SignatureRequestResponseCustomFieldBase { @@ -75,6 +72,23 @@ class SignatureRequestResponseCustomFieldCheckbox extends SignatureRequestRespon 'value' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'value' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -95,6 +109,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -170,33 +228,51 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'checkbox'; - $this->container['value'] = $data['value'] ?? null; + $this->setIfExists('type', $data ?? [], 'checkbox'); + $this->setIfExists('value', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SignatureRequestResponseCustomFieldCheckbox { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SignatureRequestResponseCustomFieldCheckbox { - /** @var SignatureRequestResponseCustomFieldCheckbox $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SignatureRequestResponseCustomFieldCheckbox */ + return ObjectSerializer::deserialize( $data, SignatureRequestResponseCustomFieldCheckbox::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -211,7 +287,6 @@ public function listInvalidProperties() if ($this->container['type'] === null) { $invalidProperties[] = "'type' can't be null"; } - return $invalidProperties; } @@ -245,6 +320,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -269,6 +347,9 @@ public function getValue() */ public function setValue(?bool $value) { + if (is_null($value)) { + throw new InvalidArgumentException('non-nullable value cannot be null'); + } $this->container['value'] = $value; return $this; @@ -277,12 +358,10 @@ public function setValue(?bool $value) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -290,7 +369,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -303,13 +382,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -321,12 +398,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -335,8 +410,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SignatureRequestResponseCustomFieldText.php b/sdks/php/src/Model/SignatureRequestResponseCustomFieldText.php index ac1300a8e..4115fc171 100644 --- a/sdks/php/src/Model/SignatureRequestResponseCustomFieldText.php +++ b/sdks/php/src/Model/SignatureRequestResponseCustomFieldText.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,6 +28,7 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** @@ -36,11 +36,8 @@ * * @category Class * @description This class extends `SignatureRequestResponseCustomFieldBase`. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SignatureRequestResponseCustomFieldText extends SignatureRequestResponseCustomFieldBase { @@ -75,6 +72,23 @@ class SignatureRequestResponseCustomFieldText extends SignatureRequestResponseCu 'value' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'value' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -95,6 +109,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -170,33 +228,51 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'text'; - $this->container['value'] = $data['value'] ?? null; + $this->setIfExists('type', $data ?? [], 'text'); + $this->setIfExists('value', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SignatureRequestResponseCustomFieldText { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SignatureRequestResponseCustomFieldText { - /** @var SignatureRequestResponseCustomFieldText $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SignatureRequestResponseCustomFieldText */ + return ObjectSerializer::deserialize( $data, SignatureRequestResponseCustomFieldText::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -211,7 +287,6 @@ public function listInvalidProperties() if ($this->container['type'] === null) { $invalidProperties[] = "'type' can't be null"; } - return $invalidProperties; } @@ -245,6 +320,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -269,6 +347,9 @@ public function getValue() */ public function setValue(?string $value) { + if (is_null($value)) { + throw new InvalidArgumentException('non-nullable value cannot be null'); + } $this->container['value'] = $value; return $this; @@ -277,12 +358,10 @@ public function setValue(?string $value) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -290,7 +369,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -303,13 +382,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -321,12 +398,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -335,8 +410,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SignatureRequestResponseCustomFieldTypeEnum.php b/sdks/php/src/Model/SignatureRequestResponseCustomFieldTypeEnum.php index d5a610466..c9f4ea0a2 100644 --- a/sdks/php/src/Model/SignatureRequestResponseCustomFieldTypeEnum.php +++ b/sdks/php/src/Model/SignatureRequestResponseCustomFieldTypeEnum.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -32,7 +31,6 @@ * SignatureRequestResponseCustomFieldTypeEnum Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ class SignatureRequestResponseCustomFieldTypeEnum diff --git a/sdks/php/src/Model/SignatureRequestResponseDataBase.php b/sdks/php/src/Model/SignatureRequestResponseDataBase.php index 5b564fec5..5f473fe7f 100644 --- a/sdks/php/src/Model/SignatureRequestResponseDataBase.php +++ b/sdks/php/src/Model/SignatureRequestResponseDataBase.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,14 +38,10 @@ * * @category Class * @description An array of form field objects containing the name, value, and type of each textbox or checkmark field filled in by the signers. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ -abstract class SignatureRequestResponseDataBase implements ModelInterface, ArrayAccess, JsonSerializable +class SignatureRequestResponseDataBase implements ModelInterface, ArrayAccess, JsonSerializable { public const DISCRIMINATOR = 'type'; @@ -84,6 +80,26 @@ abstract class SignatureRequestResponseDataBase implements ModelInterface, Array 'type' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'api_id' => false, + 'signature_id' => false, + 'name' => false, + 'required' => false, + 'type' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -104,6 +120,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -188,23 +248,23 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['api_id'] = $data['api_id'] ?? null; - $this->container['signature_id'] = $data['signature_id'] ?? null; - $this->container['name'] = $data['name'] ?? null; - $this->container['required'] = $data['required'] ?? null; - $this->container['type'] = $data['type'] ?? null; + $this->setIfExists('api_id', $data ?? [], null); + $this->setIfExists('signature_id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('required', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); // Initialize discriminator property with the model name. $this->container['type'] = static::$openAPIModelName; @@ -247,6 +307,22 @@ public static function discriminatorClassName(array $data): ?string return null; } + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + /** * Show all the invalid properties with reasons. * @@ -254,9 +330,7 @@ public static function discriminatorClassName(array $data): ?string */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -289,6 +363,9 @@ public function getApiId() */ public function setApiId(?string $api_id) { + if (is_null($api_id)) { + throw new InvalidArgumentException('non-nullable api_id cannot be null'); + } $this->container['api_id'] = $api_id; return $this; @@ -313,6 +390,9 @@ public function getSignatureId() */ public function setSignatureId(?string $signature_id) { + if (is_null($signature_id)) { + throw new InvalidArgumentException('non-nullable signature_id cannot be null'); + } $this->container['signature_id'] = $signature_id; return $this; @@ -337,6 +417,9 @@ public function getName() */ public function setName(?string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -361,6 +444,9 @@ public function getRequired() */ public function setRequired(?bool $required) { + if (is_null($required)) { + throw new InvalidArgumentException('non-nullable required cannot be null'); + } $this->container['required'] = $required; return $this; @@ -385,6 +471,9 @@ public function getType() */ public function setType(?string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -393,12 +482,10 @@ public function setType(?string $type) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -406,7 +493,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -419,13 +506,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -437,12 +522,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -451,8 +534,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SignatureRequestResponseDataTypeEnum.php b/sdks/php/src/Model/SignatureRequestResponseDataTypeEnum.php index bb4ea4b1c..fd4b6e268 100644 --- a/sdks/php/src/Model/SignatureRequestResponseDataTypeEnum.php +++ b/sdks/php/src/Model/SignatureRequestResponseDataTypeEnum.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -32,7 +31,6 @@ * SignatureRequestResponseDataTypeEnum Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ class SignatureRequestResponseDataTypeEnum diff --git a/sdks/php/src/Model/SignatureRequestResponseDataValueCheckbox.php b/sdks/php/src/Model/SignatureRequestResponseDataValueCheckbox.php index 45bf82397..c64a1fbc7 100644 --- a/sdks/php/src/Model/SignatureRequestResponseDataValueCheckbox.php +++ b/sdks/php/src/Model/SignatureRequestResponseDataValueCheckbox.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,17 +28,15 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** * SignatureRequestResponseDataValueCheckbox Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SignatureRequestResponseDataValueCheckbox extends SignatureRequestResponseDataBase { @@ -74,6 +71,23 @@ class SignatureRequestResponseDataValueCheckbox extends SignatureRequestResponse 'value' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'value' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -94,6 +108,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -169,33 +227,51 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'checkbox'; - $this->container['value'] = $data['value'] ?? null; + $this->setIfExists('type', $data ?? [], 'checkbox'); + $this->setIfExists('value', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SignatureRequestResponseDataValueCheckbox { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SignatureRequestResponseDataValueCheckbox { - /** @var SignatureRequestResponseDataValueCheckbox $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SignatureRequestResponseDataValueCheckbox */ + return ObjectSerializer::deserialize( $data, SignatureRequestResponseDataValueCheckbox::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -205,9 +281,7 @@ public static function init(array $data): SignatureRequestResponseDataValueCheck */ public function listInvalidProperties() { - $invalidProperties = parent::listInvalidProperties(); - - return $invalidProperties; + return parent::listInvalidProperties(); } /** @@ -240,6 +314,9 @@ public function getType() */ public function setType(?string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -264,6 +341,9 @@ public function getValue() */ public function setValue(?bool $value) { + if (is_null($value)) { + throw new InvalidArgumentException('non-nullable value cannot be null'); + } $this->container['value'] = $value; return $this; @@ -272,12 +352,10 @@ public function setValue(?bool $value) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -285,7 +363,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -298,13 +376,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -316,12 +392,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -330,8 +404,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SignatureRequestResponseDataValueCheckboxMerge.php b/sdks/php/src/Model/SignatureRequestResponseDataValueCheckboxMerge.php index db8fb4819..96ac1dd3e 100644 --- a/sdks/php/src/Model/SignatureRequestResponseDataValueCheckboxMerge.php +++ b/sdks/php/src/Model/SignatureRequestResponseDataValueCheckboxMerge.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,17 +28,15 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** * SignatureRequestResponseDataValueCheckboxMerge Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SignatureRequestResponseDataValueCheckboxMerge extends SignatureRequestResponseDataBase { @@ -74,6 +71,23 @@ class SignatureRequestResponseDataValueCheckboxMerge extends SignatureRequestRes 'value' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'value' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -94,6 +108,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -169,33 +227,51 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'checkbox-merge'; - $this->container['value'] = $data['value'] ?? null; + $this->setIfExists('type', $data ?? [], 'checkbox-merge'); + $this->setIfExists('value', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SignatureRequestResponseDataValueCheckboxMerge { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SignatureRequestResponseDataValueCheckboxMerge { - /** @var SignatureRequestResponseDataValueCheckboxMerge $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SignatureRequestResponseDataValueCheckboxMerge */ + return ObjectSerializer::deserialize( $data, SignatureRequestResponseDataValueCheckboxMerge::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -205,9 +281,7 @@ public static function init(array $data): SignatureRequestResponseDataValueCheck */ public function listInvalidProperties() { - $invalidProperties = parent::listInvalidProperties(); - - return $invalidProperties; + return parent::listInvalidProperties(); } /** @@ -240,6 +314,9 @@ public function getType() */ public function setType(?string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -264,6 +341,9 @@ public function getValue() */ public function setValue(?string $value) { + if (is_null($value)) { + throw new InvalidArgumentException('non-nullable value cannot be null'); + } $this->container['value'] = $value; return $this; @@ -272,12 +352,10 @@ public function setValue(?string $value) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -285,7 +363,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -298,13 +376,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -316,12 +392,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -330,8 +404,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SignatureRequestResponseDataValueDateSigned.php b/sdks/php/src/Model/SignatureRequestResponseDataValueDateSigned.php index 792407548..78c8794e0 100644 --- a/sdks/php/src/Model/SignatureRequestResponseDataValueDateSigned.php +++ b/sdks/php/src/Model/SignatureRequestResponseDataValueDateSigned.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,17 +28,15 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** * SignatureRequestResponseDataValueDateSigned Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SignatureRequestResponseDataValueDateSigned extends SignatureRequestResponseDataBase { @@ -74,6 +71,23 @@ class SignatureRequestResponseDataValueDateSigned extends SignatureRequestRespon 'value' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'value' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -94,6 +108,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -169,33 +227,51 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'date_signed'; - $this->container['value'] = $data['value'] ?? null; + $this->setIfExists('type', $data ?? [], 'date_signed'); + $this->setIfExists('value', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SignatureRequestResponseDataValueDateSigned { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SignatureRequestResponseDataValueDateSigned { - /** @var SignatureRequestResponseDataValueDateSigned $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SignatureRequestResponseDataValueDateSigned */ + return ObjectSerializer::deserialize( $data, SignatureRequestResponseDataValueDateSigned::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -205,9 +281,7 @@ public static function init(array $data): SignatureRequestResponseDataValueDateS */ public function listInvalidProperties() { - $invalidProperties = parent::listInvalidProperties(); - - return $invalidProperties; + return parent::listInvalidProperties(); } /** @@ -240,6 +314,9 @@ public function getType() */ public function setType(?string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -264,6 +341,9 @@ public function getValue() */ public function setValue(?string $value) { + if (is_null($value)) { + throw new InvalidArgumentException('non-nullable value cannot be null'); + } $this->container['value'] = $value; return $this; @@ -272,12 +352,10 @@ public function setValue(?string $value) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -285,7 +363,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -298,13 +376,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -316,12 +392,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -330,8 +404,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SignatureRequestResponseDataValueDropdown.php b/sdks/php/src/Model/SignatureRequestResponseDataValueDropdown.php index f4ac50109..4171a5860 100644 --- a/sdks/php/src/Model/SignatureRequestResponseDataValueDropdown.php +++ b/sdks/php/src/Model/SignatureRequestResponseDataValueDropdown.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,17 +28,15 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** * SignatureRequestResponseDataValueDropdown Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SignatureRequestResponseDataValueDropdown extends SignatureRequestResponseDataBase { @@ -74,6 +71,23 @@ class SignatureRequestResponseDataValueDropdown extends SignatureRequestResponse 'value' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'value' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -94,6 +108,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -169,33 +227,51 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'dropdown'; - $this->container['value'] = $data['value'] ?? null; + $this->setIfExists('type', $data ?? [], 'dropdown'); + $this->setIfExists('value', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SignatureRequestResponseDataValueDropdown { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SignatureRequestResponseDataValueDropdown { - /** @var SignatureRequestResponseDataValueDropdown $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SignatureRequestResponseDataValueDropdown */ + return ObjectSerializer::deserialize( $data, SignatureRequestResponseDataValueDropdown::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -205,9 +281,7 @@ public static function init(array $data): SignatureRequestResponseDataValueDropd */ public function listInvalidProperties() { - $invalidProperties = parent::listInvalidProperties(); - - return $invalidProperties; + return parent::listInvalidProperties(); } /** @@ -240,6 +314,9 @@ public function getType() */ public function setType(?string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -264,6 +341,9 @@ public function getValue() */ public function setValue(?string $value) { + if (is_null($value)) { + throw new InvalidArgumentException('non-nullable value cannot be null'); + } $this->container['value'] = $value; return $this; @@ -272,12 +352,10 @@ public function setValue(?string $value) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -285,7 +363,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -298,13 +376,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -316,12 +392,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -330,8 +404,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SignatureRequestResponseDataValueInitials.php b/sdks/php/src/Model/SignatureRequestResponseDataValueInitials.php index 4276a4e78..30ab1f375 100644 --- a/sdks/php/src/Model/SignatureRequestResponseDataValueInitials.php +++ b/sdks/php/src/Model/SignatureRequestResponseDataValueInitials.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,17 +28,15 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** * SignatureRequestResponseDataValueInitials Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SignatureRequestResponseDataValueInitials extends SignatureRequestResponseDataBase { @@ -74,6 +71,23 @@ class SignatureRequestResponseDataValueInitials extends SignatureRequestResponse 'value' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'value' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -94,6 +108,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -169,33 +227,51 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'initials'; - $this->container['value'] = $data['value'] ?? null; + $this->setIfExists('type', $data ?? [], 'initials'); + $this->setIfExists('value', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SignatureRequestResponseDataValueInitials { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SignatureRequestResponseDataValueInitials { - /** @var SignatureRequestResponseDataValueInitials $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SignatureRequestResponseDataValueInitials */ + return ObjectSerializer::deserialize( $data, SignatureRequestResponseDataValueInitials::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -205,9 +281,7 @@ public static function init(array $data): SignatureRequestResponseDataValueIniti */ public function listInvalidProperties() { - $invalidProperties = parent::listInvalidProperties(); - - return $invalidProperties; + return parent::listInvalidProperties(); } /** @@ -240,6 +314,9 @@ public function getType() */ public function setType(?string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -264,6 +341,9 @@ public function getValue() */ public function setValue(?string $value) { + if (is_null($value)) { + throw new InvalidArgumentException('non-nullable value cannot be null'); + } $this->container['value'] = $value; return $this; @@ -272,12 +352,10 @@ public function setValue(?string $value) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -285,7 +363,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -298,13 +376,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -316,12 +392,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -330,8 +404,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SignatureRequestResponseDataValueRadio.php b/sdks/php/src/Model/SignatureRequestResponseDataValueRadio.php index 7d502feca..0c05b0bc9 100644 --- a/sdks/php/src/Model/SignatureRequestResponseDataValueRadio.php +++ b/sdks/php/src/Model/SignatureRequestResponseDataValueRadio.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,17 +28,15 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** * SignatureRequestResponseDataValueRadio Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SignatureRequestResponseDataValueRadio extends SignatureRequestResponseDataBase { @@ -74,6 +71,23 @@ class SignatureRequestResponseDataValueRadio extends SignatureRequestResponseDat 'value' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'value' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -94,6 +108,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -169,33 +227,51 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'radio'; - $this->container['value'] = $data['value'] ?? null; + $this->setIfExists('type', $data ?? [], 'radio'); + $this->setIfExists('value', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SignatureRequestResponseDataValueRadio { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SignatureRequestResponseDataValueRadio { - /** @var SignatureRequestResponseDataValueRadio $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SignatureRequestResponseDataValueRadio */ + return ObjectSerializer::deserialize( $data, SignatureRequestResponseDataValueRadio::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -205,9 +281,7 @@ public static function init(array $data): SignatureRequestResponseDataValueRadio */ public function listInvalidProperties() { - $invalidProperties = parent::listInvalidProperties(); - - return $invalidProperties; + return parent::listInvalidProperties(); } /** @@ -240,6 +314,9 @@ public function getType() */ public function setType(?string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -264,6 +341,9 @@ public function getValue() */ public function setValue(?bool $value) { + if (is_null($value)) { + throw new InvalidArgumentException('non-nullable value cannot be null'); + } $this->container['value'] = $value; return $this; @@ -272,12 +352,10 @@ public function setValue(?bool $value) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -285,7 +363,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -298,13 +376,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -316,12 +392,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -330,8 +404,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SignatureRequestResponseDataValueSignature.php b/sdks/php/src/Model/SignatureRequestResponseDataValueSignature.php index bbdcfb16a..458a052a7 100644 --- a/sdks/php/src/Model/SignatureRequestResponseDataValueSignature.php +++ b/sdks/php/src/Model/SignatureRequestResponseDataValueSignature.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,17 +28,15 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** * SignatureRequestResponseDataValueSignature Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SignatureRequestResponseDataValueSignature extends SignatureRequestResponseDataBase { @@ -74,6 +71,23 @@ class SignatureRequestResponseDataValueSignature extends SignatureRequestRespons 'value' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'value' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -94,6 +108,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -169,33 +227,51 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'signature'; - $this->container['value'] = $data['value'] ?? null; + $this->setIfExists('type', $data ?? [], 'signature'); + $this->setIfExists('value', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SignatureRequestResponseDataValueSignature { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SignatureRequestResponseDataValueSignature { - /** @var SignatureRequestResponseDataValueSignature $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SignatureRequestResponseDataValueSignature */ + return ObjectSerializer::deserialize( $data, SignatureRequestResponseDataValueSignature::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -205,9 +281,7 @@ public static function init(array $data): SignatureRequestResponseDataValueSigna */ public function listInvalidProperties() { - $invalidProperties = parent::listInvalidProperties(); - - return $invalidProperties; + return parent::listInvalidProperties(); } /** @@ -240,6 +314,9 @@ public function getType() */ public function setType(?string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -264,6 +341,9 @@ public function getValue() */ public function setValue(?string $value) { + if (is_null($value)) { + throw new InvalidArgumentException('non-nullable value cannot be null'); + } $this->container['value'] = $value; return $this; @@ -272,12 +352,10 @@ public function setValue(?string $value) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -285,7 +363,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -298,13 +376,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -316,12 +392,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -330,8 +404,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SignatureRequestResponseDataValueText.php b/sdks/php/src/Model/SignatureRequestResponseDataValueText.php index d67e26738..f4ddd0ff3 100644 --- a/sdks/php/src/Model/SignatureRequestResponseDataValueText.php +++ b/sdks/php/src/Model/SignatureRequestResponseDataValueText.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,17 +28,15 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** * SignatureRequestResponseDataValueText Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SignatureRequestResponseDataValueText extends SignatureRequestResponseDataBase { @@ -74,6 +71,23 @@ class SignatureRequestResponseDataValueText extends SignatureRequestResponseData 'value' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'value' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -94,6 +108,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -169,33 +227,51 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'text'; - $this->container['value'] = $data['value'] ?? null; + $this->setIfExists('type', $data ?? [], 'text'); + $this->setIfExists('value', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SignatureRequestResponseDataValueText { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SignatureRequestResponseDataValueText { - /** @var SignatureRequestResponseDataValueText $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SignatureRequestResponseDataValueText */ + return ObjectSerializer::deserialize( $data, SignatureRequestResponseDataValueText::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -205,9 +281,7 @@ public static function init(array $data): SignatureRequestResponseDataValueText */ public function listInvalidProperties() { - $invalidProperties = parent::listInvalidProperties(); - - return $invalidProperties; + return parent::listInvalidProperties(); } /** @@ -240,6 +314,9 @@ public function getType() */ public function setType(?string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -264,6 +341,9 @@ public function getValue() */ public function setValue(?string $value) { + if (is_null($value)) { + throw new InvalidArgumentException('non-nullable value cannot be null'); + } $this->container['value'] = $value; return $this; @@ -272,12 +352,10 @@ public function setValue(?string $value) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -285,7 +363,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -298,13 +376,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -316,12 +392,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -330,8 +404,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SignatureRequestResponseDataValueTextMerge.php b/sdks/php/src/Model/SignatureRequestResponseDataValueTextMerge.php index 4dce57c71..ef64d4b8e 100644 --- a/sdks/php/src/Model/SignatureRequestResponseDataValueTextMerge.php +++ b/sdks/php/src/Model/SignatureRequestResponseDataValueTextMerge.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,17 +28,15 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** * SignatureRequestResponseDataValueTextMerge Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SignatureRequestResponseDataValueTextMerge extends SignatureRequestResponseDataBase { @@ -74,6 +71,23 @@ class SignatureRequestResponseDataValueTextMerge extends SignatureRequestRespons 'value' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'value' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -94,6 +108,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -169,33 +227,51 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'text-merge'; - $this->container['value'] = $data['value'] ?? null; + $this->setIfExists('type', $data ?? [], 'text-merge'); + $this->setIfExists('value', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SignatureRequestResponseDataValueTextMerge { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SignatureRequestResponseDataValueTextMerge { - /** @var SignatureRequestResponseDataValueTextMerge $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SignatureRequestResponseDataValueTextMerge */ + return ObjectSerializer::deserialize( $data, SignatureRequestResponseDataValueTextMerge::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -205,9 +281,7 @@ public static function init(array $data): SignatureRequestResponseDataValueTextM */ public function listInvalidProperties() { - $invalidProperties = parent::listInvalidProperties(); - - return $invalidProperties; + return parent::listInvalidProperties(); } /** @@ -240,6 +314,9 @@ public function getType() */ public function setType(?string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -264,6 +341,9 @@ public function getValue() */ public function setValue(?string $value) { + if (is_null($value)) { + throw new InvalidArgumentException('non-nullable value cannot be null'); + } $this->container['value'] = $value; return $this; @@ -272,12 +352,10 @@ public function setValue(?string $value) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -285,7 +363,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -298,13 +376,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -316,12 +392,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -330,8 +404,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SignatureRequestResponseSignatures.php b/sdks/php/src/Model/SignatureRequestResponseSignatures.php index 87fb09f3d..081ebb6d3 100644 --- a/sdks/php/src/Model/SignatureRequestResponseSignatures.php +++ b/sdks/php/src/Model/SignatureRequestResponseSignatures.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,12 +38,8 @@ * * @category Class * @description An array of signature objects, 1 for each signer. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class SignatureRequestResponseSignatures implements ModelInterface, ArrayAccess, JsonSerializable { @@ -112,6 +108,40 @@ class SignatureRequestResponseSignatures implements ModelInterface, ArrayAccess, 'error' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'signature_id' => false, + 'signer_group_guid' => true, + 'signer_email_address' => false, + 'signer_name' => true, + 'signer_role' => true, + 'order' => true, + 'status_code' => false, + 'decline_reason' => true, + 'signed_at' => true, + 'last_viewed_at' => true, + 'last_reminded_at' => true, + 'has_pin' => false, + 'has_sms_auth' => true, + 'has_sms_delivery' => true, + 'sms_phone_number' => true, + 'reassigned_by' => true, + 'reassignment_reason' => true, + 'reassigned_from' => true, + 'error' => true, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -132,6 +162,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -258,55 +332,73 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['signature_id'] = $data['signature_id'] ?? null; - $this->container['signer_group_guid'] = $data['signer_group_guid'] ?? null; - $this->container['signer_email_address'] = $data['signer_email_address'] ?? null; - $this->container['signer_name'] = $data['signer_name'] ?? null; - $this->container['signer_role'] = $data['signer_role'] ?? null; - $this->container['order'] = $data['order'] ?? null; - $this->container['status_code'] = $data['status_code'] ?? null; - $this->container['decline_reason'] = $data['decline_reason'] ?? null; - $this->container['signed_at'] = $data['signed_at'] ?? null; - $this->container['last_viewed_at'] = $data['last_viewed_at'] ?? null; - $this->container['last_reminded_at'] = $data['last_reminded_at'] ?? null; - $this->container['has_pin'] = $data['has_pin'] ?? null; - $this->container['has_sms_auth'] = $data['has_sms_auth'] ?? null; - $this->container['has_sms_delivery'] = $data['has_sms_delivery'] ?? null; - $this->container['sms_phone_number'] = $data['sms_phone_number'] ?? null; - $this->container['reassigned_by'] = $data['reassigned_by'] ?? null; - $this->container['reassignment_reason'] = $data['reassignment_reason'] ?? null; - $this->container['reassigned_from'] = $data['reassigned_from'] ?? null; - $this->container['error'] = $data['error'] ?? null; - } - - /** @deprecated use ::init() */ + $this->setIfExists('signature_id', $data ?? [], null); + $this->setIfExists('signer_group_guid', $data ?? [], null); + $this->setIfExists('signer_email_address', $data ?? [], null); + $this->setIfExists('signer_name', $data ?? [], null); + $this->setIfExists('signer_role', $data ?? [], null); + $this->setIfExists('order', $data ?? [], null); + $this->setIfExists('status_code', $data ?? [], null); + $this->setIfExists('decline_reason', $data ?? [], null); + $this->setIfExists('signed_at', $data ?? [], null); + $this->setIfExists('last_viewed_at', $data ?? [], null); + $this->setIfExists('last_reminded_at', $data ?? [], null); + $this->setIfExists('has_pin', $data ?? [], null); + $this->setIfExists('has_sms_auth', $data ?? [], null); + $this->setIfExists('has_sms_delivery', $data ?? [], null); + $this->setIfExists('sms_phone_number', $data ?? [], null); + $this->setIfExists('reassigned_by', $data ?? [], null); + $this->setIfExists('reassignment_reason', $data ?? [], null); + $this->setIfExists('reassigned_from', $data ?? [], null); + $this->setIfExists('error', $data ?? [], null); + } + + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SignatureRequestResponseSignatures { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SignatureRequestResponseSignatures { - /** @var SignatureRequestResponseSignatures $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SignatureRequestResponseSignatures */ + return ObjectSerializer::deserialize( $data, SignatureRequestResponseSignatures::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -316,9 +408,7 @@ public static function init(array $data): SignatureRequestResponseSignatures */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -351,6 +441,9 @@ public function getSignatureId() */ public function setSignatureId(?string $signature_id) { + if (is_null($signature_id)) { + throw new InvalidArgumentException('non-nullable signature_id cannot be null'); + } $this->container['signature_id'] = $signature_id; return $this; @@ -375,6 +468,16 @@ public function getSignerGroupGuid() */ public function setSignerGroupGuid(?string $signer_group_guid) { + if (is_null($signer_group_guid)) { + array_push($this->openAPINullablesSetToNull, 'signer_group_guid'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('signer_group_guid', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['signer_group_guid'] = $signer_group_guid; return $this; @@ -399,6 +502,9 @@ public function getSignerEmailAddress() */ public function setSignerEmailAddress(?string $signer_email_address) { + if (is_null($signer_email_address)) { + throw new InvalidArgumentException('non-nullable signer_email_address cannot be null'); + } $this->container['signer_email_address'] = $signer_email_address; return $this; @@ -423,6 +529,16 @@ public function getSignerName() */ public function setSignerName(?string $signer_name) { + if (is_null($signer_name)) { + array_push($this->openAPINullablesSetToNull, 'signer_name'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('signer_name', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['signer_name'] = $signer_name; return $this; @@ -447,6 +563,16 @@ public function getSignerRole() */ public function setSignerRole(?string $signer_role) { + if (is_null($signer_role)) { + array_push($this->openAPINullablesSetToNull, 'signer_role'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('signer_role', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['signer_role'] = $signer_role; return $this; @@ -471,6 +597,16 @@ public function getOrder() */ public function setOrder(?int $order) { + if (is_null($order)) { + array_push($this->openAPINullablesSetToNull, 'order'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('order', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['order'] = $order; return $this; @@ -495,6 +631,9 @@ public function getStatusCode() */ public function setStatusCode(?string $status_code) { + if (is_null($status_code)) { + throw new InvalidArgumentException('non-nullable status_code cannot be null'); + } $this->container['status_code'] = $status_code; return $this; @@ -519,6 +658,16 @@ public function getDeclineReason() */ public function setDeclineReason(?string $decline_reason) { + if (is_null($decline_reason)) { + array_push($this->openAPINullablesSetToNull, 'decline_reason'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('decline_reason', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['decline_reason'] = $decline_reason; return $this; @@ -543,6 +692,16 @@ public function getSignedAt() */ public function setSignedAt(?int $signed_at) { + if (is_null($signed_at)) { + array_push($this->openAPINullablesSetToNull, 'signed_at'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('signed_at', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['signed_at'] = $signed_at; return $this; @@ -567,6 +726,16 @@ public function getLastViewedAt() */ public function setLastViewedAt(?int $last_viewed_at) { + if (is_null($last_viewed_at)) { + array_push($this->openAPINullablesSetToNull, 'last_viewed_at'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('last_viewed_at', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['last_viewed_at'] = $last_viewed_at; return $this; @@ -591,6 +760,16 @@ public function getLastRemindedAt() */ public function setLastRemindedAt(?int $last_reminded_at) { + if (is_null($last_reminded_at)) { + array_push($this->openAPINullablesSetToNull, 'last_reminded_at'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('last_reminded_at', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['last_reminded_at'] = $last_reminded_at; return $this; @@ -615,6 +794,9 @@ public function getHasPin() */ public function setHasPin(?bool $has_pin) { + if (is_null($has_pin)) { + throw new InvalidArgumentException('non-nullable has_pin cannot be null'); + } $this->container['has_pin'] = $has_pin; return $this; @@ -639,6 +821,16 @@ public function getHasSmsAuth() */ public function setHasSmsAuth(?bool $has_sms_auth) { + if (is_null($has_sms_auth)) { + array_push($this->openAPINullablesSetToNull, 'has_sms_auth'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('has_sms_auth', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['has_sms_auth'] = $has_sms_auth; return $this; @@ -663,6 +855,16 @@ public function getHasSmsDelivery() */ public function setHasSmsDelivery(?bool $has_sms_delivery) { + if (is_null($has_sms_delivery)) { + array_push($this->openAPINullablesSetToNull, 'has_sms_delivery'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('has_sms_delivery', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['has_sms_delivery'] = $has_sms_delivery; return $this; @@ -687,6 +889,16 @@ public function getSmsPhoneNumber() */ public function setSmsPhoneNumber(?string $sms_phone_number) { + if (is_null($sms_phone_number)) { + array_push($this->openAPINullablesSetToNull, 'sms_phone_number'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('sms_phone_number', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['sms_phone_number'] = $sms_phone_number; return $this; @@ -711,6 +923,16 @@ public function getReassignedBy() */ public function setReassignedBy(?string $reassigned_by) { + if (is_null($reassigned_by)) { + array_push($this->openAPINullablesSetToNull, 'reassigned_by'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('reassigned_by', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['reassigned_by'] = $reassigned_by; return $this; @@ -735,6 +957,16 @@ public function getReassignmentReason() */ public function setReassignmentReason(?string $reassignment_reason) { + if (is_null($reassignment_reason)) { + array_push($this->openAPINullablesSetToNull, 'reassignment_reason'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('reassignment_reason', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['reassignment_reason'] = $reassignment_reason; return $this; @@ -759,6 +991,16 @@ public function getReassignedFrom() */ public function setReassignedFrom(?string $reassigned_from) { + if (is_null($reassigned_from)) { + array_push($this->openAPINullablesSetToNull, 'reassigned_from'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('reassigned_from', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['reassigned_from'] = $reassigned_from; return $this; @@ -783,6 +1025,16 @@ public function getError() */ public function setError(?string $error) { + if (is_null($error)) { + array_push($this->openAPINullablesSetToNull, 'error'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('error', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['error'] = $error; return $this; @@ -791,12 +1043,10 @@ public function setError(?string $error) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -804,7 +1054,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -817,13 +1067,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -835,12 +1083,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -849,8 +1095,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SignatureRequestSendRequest.php b/sdks/php/src/Model/SignatureRequestSendRequest.php index c68fb8f49..600ee133e 100644 --- a/sdks/php/src/Model/SignatureRequestSendRequest.php +++ b/sdks/php/src/Model/SignatureRequestSendRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -39,11 +38,8 @@ * SignatureRequestSendRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SignatureRequestSendRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -126,6 +122,47 @@ class SignatureRequestSendRequest implements ModelInterface, ArrayAccess, JsonSe 'expires_at' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'files' => false, + 'file_urls' => false, + 'signers' => false, + 'grouped_signers' => false, + 'allow_decline' => false, + 'allow_reassign' => false, + 'attachments' => false, + 'cc_email_addresses' => false, + 'client_id' => false, + 'custom_fields' => false, + 'field_options' => false, + 'form_field_groups' => false, + 'form_field_rules' => false, + 'form_fields_per_document' => false, + 'hide_text_tags' => false, + 'is_qualified_signature' => false, + 'is_eid' => false, + 'message' => false, + 'metadata' => false, + 'signing_options' => false, + 'signing_redirect_url' => false, + 'subject' => false, + 'test_mode' => false, + 'title' => false, + 'use_text_tags' => false, + 'expires_at' => true, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -146,6 +183,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -293,62 +374,80 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['files'] = $data['files'] ?? null; - $this->container['file_urls'] = $data['file_urls'] ?? null; - $this->container['signers'] = $data['signers'] ?? null; - $this->container['grouped_signers'] = $data['grouped_signers'] ?? null; - $this->container['allow_decline'] = $data['allow_decline'] ?? false; - $this->container['allow_reassign'] = $data['allow_reassign'] ?? false; - $this->container['attachments'] = $data['attachments'] ?? null; - $this->container['cc_email_addresses'] = $data['cc_email_addresses'] ?? null; - $this->container['client_id'] = $data['client_id'] ?? null; - $this->container['custom_fields'] = $data['custom_fields'] ?? null; - $this->container['field_options'] = $data['field_options'] ?? null; - $this->container['form_field_groups'] = $data['form_field_groups'] ?? null; - $this->container['form_field_rules'] = $data['form_field_rules'] ?? null; - $this->container['form_fields_per_document'] = $data['form_fields_per_document'] ?? null; - $this->container['hide_text_tags'] = $data['hide_text_tags'] ?? false; - $this->container['is_qualified_signature'] = $data['is_qualified_signature'] ?? false; - $this->container['is_eid'] = $data['is_eid'] ?? false; - $this->container['message'] = $data['message'] ?? null; - $this->container['metadata'] = $data['metadata'] ?? null; - $this->container['signing_options'] = $data['signing_options'] ?? null; - $this->container['signing_redirect_url'] = $data['signing_redirect_url'] ?? null; - $this->container['subject'] = $data['subject'] ?? null; - $this->container['test_mode'] = $data['test_mode'] ?? false; - $this->container['title'] = $data['title'] ?? null; - $this->container['use_text_tags'] = $data['use_text_tags'] ?? false; - $this->container['expires_at'] = $data['expires_at'] ?? null; - } - - /** @deprecated use ::init() */ + $this->setIfExists('files', $data ?? [], null); + $this->setIfExists('file_urls', $data ?? [], null); + $this->setIfExists('signers', $data ?? [], null); + $this->setIfExists('grouped_signers', $data ?? [], null); + $this->setIfExists('allow_decline', $data ?? [], false); + $this->setIfExists('allow_reassign', $data ?? [], false); + $this->setIfExists('attachments', $data ?? [], null); + $this->setIfExists('cc_email_addresses', $data ?? [], null); + $this->setIfExists('client_id', $data ?? [], null); + $this->setIfExists('custom_fields', $data ?? [], null); + $this->setIfExists('field_options', $data ?? [], null); + $this->setIfExists('form_field_groups', $data ?? [], null); + $this->setIfExists('form_field_rules', $data ?? [], null); + $this->setIfExists('form_fields_per_document', $data ?? [], null); + $this->setIfExists('hide_text_tags', $data ?? [], false); + $this->setIfExists('is_qualified_signature', $data ?? [], false); + $this->setIfExists('is_eid', $data ?? [], false); + $this->setIfExists('message', $data ?? [], null); + $this->setIfExists('metadata', $data ?? [], null); + $this->setIfExists('signing_options', $data ?? [], null); + $this->setIfExists('signing_redirect_url', $data ?? [], null); + $this->setIfExists('subject', $data ?? [], null); + $this->setIfExists('test_mode', $data ?? [], false); + $this->setIfExists('title', $data ?? [], null); + $this->setIfExists('use_text_tags', $data ?? [], false); + $this->setIfExists('expires_at', $data ?? [], null); + } + + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SignatureRequestSendRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SignatureRequestSendRequest { - /** @var SignatureRequestSendRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SignatureRequestSendRequest */ + return ObjectSerializer::deserialize( $data, SignatureRequestSendRequest::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -405,6 +504,9 @@ public function getFiles() */ public function setFiles(?array $files) { + if (is_null($files)) { + throw new InvalidArgumentException('non-nullable files cannot be null'); + } $this->container['files'] = $files; return $this; @@ -429,6 +531,9 @@ public function getFileUrls() */ public function setFileUrls(?array $file_urls) { + if (is_null($file_urls)) { + throw new InvalidArgumentException('non-nullable file_urls cannot be null'); + } $this->container['file_urls'] = $file_urls; return $this; @@ -453,6 +558,9 @@ public function getSigners() */ public function setSigners(?array $signers) { + if (is_null($signers)) { + throw new InvalidArgumentException('non-nullable signers cannot be null'); + } $this->container['signers'] = $signers; return $this; @@ -477,6 +585,9 @@ public function getGroupedSigners() */ public function setGroupedSigners(?array $grouped_signers) { + if (is_null($grouped_signers)) { + throw new InvalidArgumentException('non-nullable grouped_signers cannot be null'); + } $this->container['grouped_signers'] = $grouped_signers; return $this; @@ -501,6 +612,9 @@ public function getAllowDecline() */ public function setAllowDecline(?bool $allow_decline) { + if (is_null($allow_decline)) { + throw new InvalidArgumentException('non-nullable allow_decline cannot be null'); + } $this->container['allow_decline'] = $allow_decline; return $this; @@ -525,6 +639,9 @@ public function getAllowReassign() */ public function setAllowReassign(?bool $allow_reassign) { + if (is_null($allow_reassign)) { + throw new InvalidArgumentException('non-nullable allow_reassign cannot be null'); + } $this->container['allow_reassign'] = $allow_reassign; return $this; @@ -549,6 +666,9 @@ public function getAttachments() */ public function setAttachments(?array $attachments) { + if (is_null($attachments)) { + throw new InvalidArgumentException('non-nullable attachments cannot be null'); + } $this->container['attachments'] = $attachments; return $this; @@ -573,6 +693,9 @@ public function getCcEmailAddresses() */ public function setCcEmailAddresses(?array $cc_email_addresses) { + if (is_null($cc_email_addresses)) { + throw new InvalidArgumentException('non-nullable cc_email_addresses cannot be null'); + } $this->container['cc_email_addresses'] = $cc_email_addresses; return $this; @@ -597,6 +720,9 @@ public function getClientId() */ public function setClientId(?string $client_id) { + if (is_null($client_id)) { + throw new InvalidArgumentException('non-nullable client_id cannot be null'); + } $this->container['client_id'] = $client_id; return $this; @@ -621,6 +747,9 @@ public function getCustomFields() */ public function setCustomFields(?array $custom_fields) { + if (is_null($custom_fields)) { + throw new InvalidArgumentException('non-nullable custom_fields cannot be null'); + } $this->container['custom_fields'] = $custom_fields; return $this; @@ -645,6 +774,9 @@ public function getFieldOptions() */ public function setFieldOptions(?SubFieldOptions $field_options) { + if (is_null($field_options)) { + throw new InvalidArgumentException('non-nullable field_options cannot be null'); + } $this->container['field_options'] = $field_options; return $this; @@ -669,6 +801,9 @@ public function getFormFieldGroups() */ public function setFormFieldGroups(?array $form_field_groups) { + if (is_null($form_field_groups)) { + throw new InvalidArgumentException('non-nullable form_field_groups cannot be null'); + } $this->container['form_field_groups'] = $form_field_groups; return $this; @@ -693,6 +828,9 @@ public function getFormFieldRules() */ public function setFormFieldRules(?array $form_field_rules) { + if (is_null($form_field_rules)) { + throw new InvalidArgumentException('non-nullable form_field_rules cannot be null'); + } $this->container['form_field_rules'] = $form_field_rules; return $this; @@ -717,6 +855,9 @@ public function getFormFieldsPerDocument() */ public function setFormFieldsPerDocument(?array $form_fields_per_document) { + if (is_null($form_fields_per_document)) { + throw new InvalidArgumentException('non-nullable form_fields_per_document cannot be null'); + } $this->container['form_fields_per_document'] = $form_fields_per_document; return $this; @@ -741,6 +882,9 @@ public function getHideTextTags() */ public function setHideTextTags(?bool $hide_text_tags) { + if (is_null($hide_text_tags)) { + throw new InvalidArgumentException('non-nullable hide_text_tags cannot be null'); + } $this->container['hide_text_tags'] = $hide_text_tags; return $this; @@ -767,6 +911,9 @@ public function getIsQualifiedSignature() */ public function setIsQualifiedSignature(?bool $is_qualified_signature) { + if (is_null($is_qualified_signature)) { + throw new InvalidArgumentException('non-nullable is_qualified_signature cannot be null'); + } $this->container['is_qualified_signature'] = $is_qualified_signature; return $this; @@ -791,6 +938,9 @@ public function getIsEid() */ public function setIsEid(?bool $is_eid) { + if (is_null($is_eid)) { + throw new InvalidArgumentException('non-nullable is_eid cannot be null'); + } $this->container['is_eid'] = $is_eid; return $this; @@ -815,7 +965,10 @@ public function getMessage() */ public function setMessage(?string $message) { - if (!is_null($message) && (mb_strlen($message) > 5000)) { + if (is_null($message)) { + throw new InvalidArgumentException('non-nullable message cannot be null'); + } + if (mb_strlen($message) > 5000) { throw new InvalidArgumentException('invalid length for $message when calling SignatureRequestSendRequest., must be smaller than or equal to 5000.'); } @@ -843,6 +996,10 @@ public function getMetadata() */ public function setMetadata(?array $metadata) { + if (is_null($metadata)) { + throw new InvalidArgumentException('non-nullable metadata cannot be null'); + } + $this->container['metadata'] = $metadata; return $this; @@ -867,6 +1024,9 @@ public function getSigningOptions() */ public function setSigningOptions(?SubSigningOptions $signing_options) { + if (is_null($signing_options)) { + throw new InvalidArgumentException('non-nullable signing_options cannot be null'); + } $this->container['signing_options'] = $signing_options; return $this; @@ -891,6 +1051,9 @@ public function getSigningRedirectUrl() */ public function setSigningRedirectUrl(?string $signing_redirect_url) { + if (is_null($signing_redirect_url)) { + throw new InvalidArgumentException('non-nullable signing_redirect_url cannot be null'); + } $this->container['signing_redirect_url'] = $signing_redirect_url; return $this; @@ -915,7 +1078,10 @@ public function getSubject() */ public function setSubject(?string $subject) { - if (!is_null($subject) && (mb_strlen($subject) > 255)) { + if (is_null($subject)) { + throw new InvalidArgumentException('non-nullable subject cannot be null'); + } + if (mb_strlen($subject) > 255) { throw new InvalidArgumentException('invalid length for $subject when calling SignatureRequestSendRequest., must be smaller than or equal to 255.'); } @@ -943,6 +1109,9 @@ public function getTestMode() */ public function setTestMode(?bool $test_mode) { + if (is_null($test_mode)) { + throw new InvalidArgumentException('non-nullable test_mode cannot be null'); + } $this->container['test_mode'] = $test_mode; return $this; @@ -967,7 +1136,10 @@ public function getTitle() */ public function setTitle(?string $title) { - if (!is_null($title) && (mb_strlen($title) > 255)) { + if (is_null($title)) { + throw new InvalidArgumentException('non-nullable title cannot be null'); + } + if (mb_strlen($title) > 255) { throw new InvalidArgumentException('invalid length for $title when calling SignatureRequestSendRequest., must be smaller than or equal to 255.'); } @@ -995,6 +1167,9 @@ public function getUseTextTags() */ public function setUseTextTags(?bool $use_text_tags) { + if (is_null($use_text_tags)) { + throw new InvalidArgumentException('non-nullable use_text_tags cannot be null'); + } $this->container['use_text_tags'] = $use_text_tags; return $this; @@ -1019,6 +1194,16 @@ public function getExpiresAt() */ public function setExpiresAt(?int $expires_at) { + if (is_null($expires_at)) { + array_push($this->openAPINullablesSetToNull, 'expires_at'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('expires_at', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['expires_at'] = $expires_at; return $this; @@ -1027,12 +1212,10 @@ public function setExpiresAt(?int $expires_at) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -1040,7 +1223,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -1053,13 +1236,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -1071,12 +1252,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -1085,8 +1264,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SignatureRequestSendWithTemplateRequest.php b/sdks/php/src/Model/SignatureRequestSendWithTemplateRequest.php index c08ce5f24..c58096632 100644 --- a/sdks/php/src/Model/SignatureRequestSendWithTemplateRequest.php +++ b/sdks/php/src/Model/SignatureRequestSendWithTemplateRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -39,11 +38,9 @@ * SignatureRequestSendWithTemplateRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team + * @description * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SignatureRequestSendWithTemplateRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -108,6 +105,38 @@ class SignatureRequestSendWithTemplateRequest implements ModelInterface, ArrayAc 'title' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'template_ids' => false, + 'signers' => false, + 'allow_decline' => false, + 'ccs' => false, + 'client_id' => false, + 'custom_fields' => false, + 'files' => false, + 'file_urls' => false, + 'is_qualified_signature' => false, + 'is_eid' => false, + 'message' => false, + 'metadata' => false, + 'signing_options' => false, + 'signing_redirect_url' => false, + 'subject' => false, + 'test_mode' => false, + 'title' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -128,6 +157,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -248,53 +321,71 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['template_ids'] = $data['template_ids'] ?? null; - $this->container['signers'] = $data['signers'] ?? null; - $this->container['allow_decline'] = $data['allow_decline'] ?? false; - $this->container['ccs'] = $data['ccs'] ?? null; - $this->container['client_id'] = $data['client_id'] ?? null; - $this->container['custom_fields'] = $data['custom_fields'] ?? null; - $this->container['files'] = $data['files'] ?? null; - $this->container['file_urls'] = $data['file_urls'] ?? null; - $this->container['is_qualified_signature'] = $data['is_qualified_signature'] ?? false; - $this->container['is_eid'] = $data['is_eid'] ?? false; - $this->container['message'] = $data['message'] ?? null; - $this->container['metadata'] = $data['metadata'] ?? null; - $this->container['signing_options'] = $data['signing_options'] ?? null; - $this->container['signing_redirect_url'] = $data['signing_redirect_url'] ?? null; - $this->container['subject'] = $data['subject'] ?? null; - $this->container['test_mode'] = $data['test_mode'] ?? false; - $this->container['title'] = $data['title'] ?? null; - } - - /** @deprecated use ::init() */ + $this->setIfExists('template_ids', $data ?? [], null); + $this->setIfExists('signers', $data ?? [], null); + $this->setIfExists('allow_decline', $data ?? [], false); + $this->setIfExists('ccs', $data ?? [], null); + $this->setIfExists('client_id', $data ?? [], null); + $this->setIfExists('custom_fields', $data ?? [], null); + $this->setIfExists('files', $data ?? [], null); + $this->setIfExists('file_urls', $data ?? [], null); + $this->setIfExists('is_qualified_signature', $data ?? [], false); + $this->setIfExists('is_eid', $data ?? [], false); + $this->setIfExists('message', $data ?? [], null); + $this->setIfExists('metadata', $data ?? [], null); + $this->setIfExists('signing_options', $data ?? [], null); + $this->setIfExists('signing_redirect_url', $data ?? [], null); + $this->setIfExists('subject', $data ?? [], null); + $this->setIfExists('test_mode', $data ?? [], false); + $this->setIfExists('title', $data ?? [], null); + } + + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SignatureRequestSendWithTemplateRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SignatureRequestSendWithTemplateRequest { - /** @var SignatureRequestSendWithTemplateRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SignatureRequestSendWithTemplateRequest */ + return ObjectSerializer::deserialize( $data, SignatureRequestSendWithTemplateRequest::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -357,6 +448,9 @@ public function getTemplateIds() */ public function setTemplateIds(array $template_ids) { + if (is_null($template_ids)) { + throw new InvalidArgumentException('non-nullable template_ids cannot be null'); + } $this->container['template_ids'] = $template_ids; return $this; @@ -381,6 +475,9 @@ public function getSigners() */ public function setSigners(array $signers) { + if (is_null($signers)) { + throw new InvalidArgumentException('non-nullable signers cannot be null'); + } $this->container['signers'] = $signers; return $this; @@ -405,6 +502,9 @@ public function getAllowDecline() */ public function setAllowDecline(?bool $allow_decline) { + if (is_null($allow_decline)) { + throw new InvalidArgumentException('non-nullable allow_decline cannot be null'); + } $this->container['allow_decline'] = $allow_decline; return $this; @@ -429,6 +529,9 @@ public function getCcs() */ public function setCcs(?array $ccs) { + if (is_null($ccs)) { + throw new InvalidArgumentException('non-nullable ccs cannot be null'); + } $this->container['ccs'] = $ccs; return $this; @@ -453,6 +556,9 @@ public function getClientId() */ public function setClientId(?string $client_id) { + if (is_null($client_id)) { + throw new InvalidArgumentException('non-nullable client_id cannot be null'); + } $this->container['client_id'] = $client_id; return $this; @@ -477,6 +583,9 @@ public function getCustomFields() */ public function setCustomFields(?array $custom_fields) { + if (is_null($custom_fields)) { + throw new InvalidArgumentException('non-nullable custom_fields cannot be null'); + } $this->container['custom_fields'] = $custom_fields; return $this; @@ -501,6 +610,9 @@ public function getFiles() */ public function setFiles(?array $files) { + if (is_null($files)) { + throw new InvalidArgumentException('non-nullable files cannot be null'); + } $this->container['files'] = $files; return $this; @@ -525,6 +637,9 @@ public function getFileUrls() */ public function setFileUrls(?array $file_urls) { + if (is_null($file_urls)) { + throw new InvalidArgumentException('non-nullable file_urls cannot be null'); + } $this->container['file_urls'] = $file_urls; return $this; @@ -551,6 +666,9 @@ public function getIsQualifiedSignature() */ public function setIsQualifiedSignature(?bool $is_qualified_signature) { + if (is_null($is_qualified_signature)) { + throw new InvalidArgumentException('non-nullable is_qualified_signature cannot be null'); + } $this->container['is_qualified_signature'] = $is_qualified_signature; return $this; @@ -575,6 +693,9 @@ public function getIsEid() */ public function setIsEid(?bool $is_eid) { + if (is_null($is_eid)) { + throw new InvalidArgumentException('non-nullable is_eid cannot be null'); + } $this->container['is_eid'] = $is_eid; return $this; @@ -599,7 +720,10 @@ public function getMessage() */ public function setMessage(?string $message) { - if (!is_null($message) && (mb_strlen($message) > 5000)) { + if (is_null($message)) { + throw new InvalidArgumentException('non-nullable message cannot be null'); + } + if (mb_strlen($message) > 5000) { throw new InvalidArgumentException('invalid length for $message when calling SignatureRequestSendWithTemplateRequest., must be smaller than or equal to 5000.'); } @@ -627,6 +751,10 @@ public function getMetadata() */ public function setMetadata(?array $metadata) { + if (is_null($metadata)) { + throw new InvalidArgumentException('non-nullable metadata cannot be null'); + } + $this->container['metadata'] = $metadata; return $this; @@ -651,6 +779,9 @@ public function getSigningOptions() */ public function setSigningOptions(?SubSigningOptions $signing_options) { + if (is_null($signing_options)) { + throw new InvalidArgumentException('non-nullable signing_options cannot be null'); + } $this->container['signing_options'] = $signing_options; return $this; @@ -675,6 +806,9 @@ public function getSigningRedirectUrl() */ public function setSigningRedirectUrl(?string $signing_redirect_url) { + if (is_null($signing_redirect_url)) { + throw new InvalidArgumentException('non-nullable signing_redirect_url cannot be null'); + } $this->container['signing_redirect_url'] = $signing_redirect_url; return $this; @@ -699,7 +833,10 @@ public function getSubject() */ public function setSubject(?string $subject) { - if (!is_null($subject) && (mb_strlen($subject) > 255)) { + if (is_null($subject)) { + throw new InvalidArgumentException('non-nullable subject cannot be null'); + } + if (mb_strlen($subject) > 255) { throw new InvalidArgumentException('invalid length for $subject when calling SignatureRequestSendWithTemplateRequest., must be smaller than or equal to 255.'); } @@ -727,6 +864,9 @@ public function getTestMode() */ public function setTestMode(?bool $test_mode) { + if (is_null($test_mode)) { + throw new InvalidArgumentException('non-nullable test_mode cannot be null'); + } $this->container['test_mode'] = $test_mode; return $this; @@ -751,7 +891,10 @@ public function getTitle() */ public function setTitle(?string $title) { - if (!is_null($title) && (mb_strlen($title) > 255)) { + if (is_null($title)) { + throw new InvalidArgumentException('non-nullable title cannot be null'); + } + if (mb_strlen($title) > 255) { throw new InvalidArgumentException('invalid length for $title when calling SignatureRequestSendWithTemplateRequest., must be smaller than or equal to 255.'); } @@ -763,12 +906,10 @@ public function setTitle(?string $title) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -776,7 +917,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -789,13 +930,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -807,12 +946,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -821,8 +958,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SignatureRequestUpdateRequest.php b/sdks/php/src/Model/SignatureRequestUpdateRequest.php index b54c560a2..2a4a33dcf 100644 --- a/sdks/php/src/Model/SignatureRequestUpdateRequest.php +++ b/sdks/php/src/Model/SignatureRequestUpdateRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * SignatureRequestUpdateRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SignatureRequestUpdateRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -80,6 +77,25 @@ class SignatureRequestUpdateRequest implements ModelInterface, ArrayAccess, Json 'expires_at' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'signature_id' => false, + 'email_address' => false, + 'name' => false, + 'expires_at' => true, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -100,6 +116,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -181,40 +241,58 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['signature_id'] = $data['signature_id'] ?? null; - $this->container['email_address'] = $data['email_address'] ?? null; - $this->container['name'] = $data['name'] ?? null; - $this->container['expires_at'] = $data['expires_at'] ?? null; + $this->setIfExists('signature_id', $data ?? [], null); + $this->setIfExists('email_address', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('expires_at', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SignatureRequestUpdateRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SignatureRequestUpdateRequest { - /** @var SignatureRequestUpdateRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SignatureRequestUpdateRequest */ + return ObjectSerializer::deserialize( $data, SignatureRequestUpdateRequest::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -229,7 +307,6 @@ public function listInvalidProperties() if ($this->container['signature_id'] === null) { $invalidProperties[] = "'signature_id' can't be null"; } - return $invalidProperties; } @@ -263,6 +340,9 @@ public function getSignatureId() */ public function setSignatureId(string $signature_id) { + if (is_null($signature_id)) { + throw new InvalidArgumentException('non-nullable signature_id cannot be null'); + } $this->container['signature_id'] = $signature_id; return $this; @@ -287,6 +367,9 @@ public function getEmailAddress() */ public function setEmailAddress(?string $email_address) { + if (is_null($email_address)) { + throw new InvalidArgumentException('non-nullable email_address cannot be null'); + } $this->container['email_address'] = $email_address; return $this; @@ -311,6 +394,9 @@ public function getName() */ public function setName(?string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -335,6 +421,16 @@ public function getExpiresAt() */ public function setExpiresAt(?int $expires_at) { + if (is_null($expires_at)) { + array_push($this->openAPINullablesSetToNull, 'expires_at'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('expires_at', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['expires_at'] = $expires_at; return $this; @@ -343,12 +439,10 @@ public function setExpiresAt(?int $expires_at) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -356,7 +450,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -369,13 +463,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -387,12 +479,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -401,8 +491,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubAttachment.php b/sdks/php/src/Model/SubAttachment.php index 20e960823..d41f3459c 100644 --- a/sdks/php/src/Model/SubAttachment.php +++ b/sdks/php/src/Model/SubAttachment.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * SubAttachment Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubAttachment implements ModelInterface, ArrayAccess, JsonSerializable { @@ -80,6 +77,25 @@ class SubAttachment implements ModelInterface, ArrayAccess, JsonSerializable 'required' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'name' => false, + 'signer_index' => false, + 'instructions' => false, + 'required' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -100,6 +116,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -181,40 +241,58 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['name'] = $data['name'] ?? null; - $this->container['signer_index'] = $data['signer_index'] ?? null; - $this->container['instructions'] = $data['instructions'] ?? null; - $this->container['required'] = $data['required'] ?? false; + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('signer_index', $data ?? [], null); + $this->setIfExists('instructions', $data ?? [], null); + $this->setIfExists('required', $data ?? [], false); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubAttachment { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubAttachment { - /** @var SubAttachment $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubAttachment */ + return ObjectSerializer::deserialize( $data, SubAttachment::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -232,7 +310,6 @@ public function listInvalidProperties() if ($this->container['signer_index'] === null) { $invalidProperties[] = "'signer_index' can't be null"; } - return $invalidProperties; } @@ -266,6 +343,9 @@ public function getName() */ public function setName(string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -290,6 +370,9 @@ public function getSignerIndex() */ public function setSignerIndex(int $signer_index) { + if (is_null($signer_index)) { + throw new InvalidArgumentException('non-nullable signer_index cannot be null'); + } $this->container['signer_index'] = $signer_index; return $this; @@ -314,6 +397,9 @@ public function getInstructions() */ public function setInstructions(?string $instructions) { + if (is_null($instructions)) { + throw new InvalidArgumentException('non-nullable instructions cannot be null'); + } $this->container['instructions'] = $instructions; return $this; @@ -338,6 +424,9 @@ public function getRequired() */ public function setRequired(?bool $required) { + if (is_null($required)) { + throw new InvalidArgumentException('non-nullable required cannot be null'); + } $this->container['required'] = $required; return $this; @@ -346,12 +435,10 @@ public function setRequired(?bool $required) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -359,7 +446,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -372,13 +459,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -390,12 +475,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -404,8 +487,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubBulkSignerList.php b/sdks/php/src/Model/SubBulkSignerList.php index be242b967..d9702bb7d 100644 --- a/sdks/php/src/Model/SubBulkSignerList.php +++ b/sdks/php/src/Model/SubBulkSignerList.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * SubBulkSignerList Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubBulkSignerList implements ModelInterface, ArrayAccess, JsonSerializable { @@ -76,6 +73,23 @@ class SubBulkSignerList implements ModelInterface, ArrayAccess, JsonSerializable 'signers' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'custom_fields' => false, + 'signers' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -96,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -171,38 +229,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['custom_fields'] = $data['custom_fields'] ?? null; - $this->container['signers'] = $data['signers'] ?? null; + $this->setIfExists('custom_fields', $data ?? [], null); + $this->setIfExists('signers', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubBulkSignerList { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubBulkSignerList { - /** @var SubBulkSignerList $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubBulkSignerList */ + return ObjectSerializer::deserialize( $data, SubBulkSignerList::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -212,9 +288,7 @@ public static function init(array $data): SubBulkSignerList */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -247,6 +321,9 @@ public function getCustomFields() */ public function setCustomFields(?array $custom_fields) { + if (is_null($custom_fields)) { + throw new InvalidArgumentException('non-nullable custom_fields cannot be null'); + } $this->container['custom_fields'] = $custom_fields; return $this; @@ -271,6 +348,9 @@ public function getSigners() */ public function setSigners(?array $signers) { + if (is_null($signers)) { + throw new InvalidArgumentException('non-nullable signers cannot be null'); + } $this->container['signers'] = $signers; return $this; @@ -279,12 +359,10 @@ public function setSigners(?array $signers) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -292,7 +370,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -305,13 +383,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -323,12 +399,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -337,8 +411,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubBulkSignerListCustomField.php b/sdks/php/src/Model/SubBulkSignerListCustomField.php index 9afee26cb..17f67ac95 100644 --- a/sdks/php/src/Model/SubBulkSignerListCustomField.php +++ b/sdks/php/src/Model/SubBulkSignerListCustomField.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * SubBulkSignerListCustomField Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubBulkSignerListCustomField implements ModelInterface, ArrayAccess, JsonSerializable { @@ -76,6 +73,23 @@ class SubBulkSignerListCustomField implements ModelInterface, ArrayAccess, JsonS 'value' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'name' => false, + 'value' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -96,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -171,38 +229,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['name'] = $data['name'] ?? null; - $this->container['value'] = $data['value'] ?? null; + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('value', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubBulkSignerListCustomField { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubBulkSignerListCustomField { - /** @var SubBulkSignerListCustomField $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubBulkSignerListCustomField */ + return ObjectSerializer::deserialize( $data, SubBulkSignerListCustomField::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -220,7 +296,6 @@ public function listInvalidProperties() if ($this->container['value'] === null) { $invalidProperties[] = "'value' can't be null"; } - return $invalidProperties; } @@ -254,6 +329,9 @@ public function getName() */ public function setName(string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -278,6 +356,9 @@ public function getValue() */ public function setValue(string $value) { + if (is_null($value)) { + throw new InvalidArgumentException('non-nullable value cannot be null'); + } $this->container['value'] = $value; return $this; @@ -286,12 +367,10 @@ public function setValue(string $value) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -299,7 +378,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -312,13 +391,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -330,12 +407,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -344,8 +419,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubCC.php b/sdks/php/src/Model/SubCC.php index c07dcfbe0..0380a3889 100644 --- a/sdks/php/src/Model/SubCC.php +++ b/sdks/php/src/Model/SubCC.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * SubCC Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubCC implements ModelInterface, ArrayAccess, JsonSerializable { @@ -76,6 +73,23 @@ class SubCC implements ModelInterface, ArrayAccess, JsonSerializable 'email_address' => 'email', ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'role' => false, + 'email_address' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -96,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -171,38 +229,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['role'] = $data['role'] ?? null; - $this->container['email_address'] = $data['email_address'] ?? null; + $this->setIfExists('role', $data ?? [], null); + $this->setIfExists('email_address', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubCC { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubCC { - /** @var SubCC $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubCC */ + return ObjectSerializer::deserialize( $data, SubCC::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -220,7 +296,6 @@ public function listInvalidProperties() if ($this->container['email_address'] === null) { $invalidProperties[] = "'email_address' can't be null"; } - return $invalidProperties; } @@ -254,6 +329,9 @@ public function getRole() */ public function setRole(string $role) { + if (is_null($role)) { + throw new InvalidArgumentException('non-nullable role cannot be null'); + } $this->container['role'] = $role; return $this; @@ -278,6 +356,9 @@ public function getEmailAddress() */ public function setEmailAddress(string $email_address) { + if (is_null($email_address)) { + throw new InvalidArgumentException('non-nullable email_address cannot be null'); + } $this->container['email_address'] = $email_address; return $this; @@ -286,12 +367,10 @@ public function setEmailAddress(string $email_address) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -299,7 +378,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -312,13 +391,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -330,12 +407,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -344,8 +419,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubCustomField.php b/sdks/php/src/Model/SubCustomField.php index 9b0342904..e853f9eb1 100644 --- a/sdks/php/src/Model/SubCustomField.php +++ b/sdks/php/src/Model/SubCustomField.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,11 +38,8 @@ * * @category Class * @description When used together with merge fields, `custom_fields` allows users to add pre-filled data to their signature requests. Pre-filled data can be used with \"send-once\" signature requests by adding merge fields with `form_fields_per_document` or [Text Tags](https://app.hellosign.com/api/textTagsWalkthrough#TextTagIntro) while passing values back with `custom_fields` together in one API call. For using pre-filled on repeatable signature requests, merge fields are added to templates in the Dropbox Sign UI or by calling [/template/create_embedded_draft](/api/reference/operation/templateCreateEmbeddedDraft) and then passing `custom_fields` on subsequent signature requests referencing that template. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubCustomField implements ModelInterface, ArrayAccess, JsonSerializable { @@ -81,6 +78,25 @@ class SubCustomField implements ModelInterface, ArrayAccess, JsonSerializable 'value' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'name' => false, + 'editor' => false, + 'required' => false, + 'value' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -101,6 +117,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -182,40 +242,58 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['name'] = $data['name'] ?? null; - $this->container['editor'] = $data['editor'] ?? null; - $this->container['required'] = $data['required'] ?? false; - $this->container['value'] = $data['value'] ?? null; + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('editor', $data ?? [], null); + $this->setIfExists('required', $data ?? [], false); + $this->setIfExists('value', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubCustomField { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubCustomField { - /** @var SubCustomField $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubCustomField */ + return ObjectSerializer::deserialize( $data, SubCustomField::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -230,7 +308,6 @@ public function listInvalidProperties() if ($this->container['name'] === null) { $invalidProperties[] = "'name' can't be null"; } - return $invalidProperties; } @@ -264,6 +341,9 @@ public function getName() */ public function setName(string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -288,6 +368,9 @@ public function getEditor() */ public function setEditor(?string $editor) { + if (is_null($editor)) { + throw new InvalidArgumentException('non-nullable editor cannot be null'); + } $this->container['editor'] = $editor; return $this; @@ -312,6 +395,9 @@ public function getRequired() */ public function setRequired(?bool $required) { + if (is_null($required)) { + throw new InvalidArgumentException('non-nullable required cannot be null'); + } $this->container['required'] = $required; return $this; @@ -336,6 +422,9 @@ public function getValue() */ public function setValue(?string $value) { + if (is_null($value)) { + throw new InvalidArgumentException('non-nullable value cannot be null'); + } $this->container['value'] = $value; return $this; @@ -344,12 +433,10 @@ public function setValue(?string $value) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -357,7 +444,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -370,13 +457,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -388,12 +473,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -402,8 +485,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubEditorOptions.php b/sdks/php/src/Model/SubEditorOptions.php index b53caa2ad..cd15d5965 100644 --- a/sdks/php/src/Model/SubEditorOptions.php +++ b/sdks/php/src/Model/SubEditorOptions.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,11 +38,8 @@ * * @category Class * @description This allows the requester to specify editor options when a preparing a document - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubEditorOptions implements ModelInterface, ArrayAccess, JsonSerializable { @@ -77,6 +74,23 @@ class SubEditorOptions implements ModelInterface, ArrayAccess, JsonSerializable 'allow_edit_documents' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'allow_edit_signers' => false, + 'allow_edit_documents' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -97,6 +111,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -172,38 +230,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['allow_edit_signers'] = $data['allow_edit_signers'] ?? false; - $this->container['allow_edit_documents'] = $data['allow_edit_documents'] ?? false; + $this->setIfExists('allow_edit_signers', $data ?? [], false); + $this->setIfExists('allow_edit_documents', $data ?? [], false); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubEditorOptions { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubEditorOptions { - /** @var SubEditorOptions $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubEditorOptions */ + return ObjectSerializer::deserialize( $data, SubEditorOptions::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -213,9 +289,7 @@ public static function init(array $data): SubEditorOptions */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -248,6 +322,9 @@ public function getAllowEditSigners() */ public function setAllowEditSigners(?bool $allow_edit_signers) { + if (is_null($allow_edit_signers)) { + throw new InvalidArgumentException('non-nullable allow_edit_signers cannot be null'); + } $this->container['allow_edit_signers'] = $allow_edit_signers; return $this; @@ -272,6 +349,9 @@ public function getAllowEditDocuments() */ public function setAllowEditDocuments(?bool $allow_edit_documents) { + if (is_null($allow_edit_documents)) { + throw new InvalidArgumentException('non-nullable allow_edit_documents cannot be null'); + } $this->container['allow_edit_documents'] = $allow_edit_documents; return $this; @@ -280,12 +360,10 @@ public function setAllowEditDocuments(?bool $allow_edit_documents) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -293,7 +371,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -306,13 +384,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -324,12 +400,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -338,8 +412,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubFieldOptions.php b/sdks/php/src/Model/SubFieldOptions.php index 3bb948219..974daa4a9 100644 --- a/sdks/php/src/Model/SubFieldOptions.php +++ b/sdks/php/src/Model/SubFieldOptions.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -39,11 +38,8 @@ * * @category Class * @description This allows the requester to specify field options for a signature request. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubFieldOptions implements ModelInterface, ArrayAccess, JsonSerializable { @@ -76,6 +72,22 @@ class SubFieldOptions implements ModelInterface, ArrayAccess, JsonSerializable 'date_format' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'date_format' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -96,6 +108,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -192,37 +248,55 @@ public function getDateFormatAllowableValues() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['date_format'] = $data['date_format'] ?? null; + $this->setIfExists('date_format', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubFieldOptions { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubFieldOptions { - /** @var SubFieldOptions $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubFieldOptions */ + return ObjectSerializer::deserialize( $data, SubFieldOptions::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -279,6 +353,9 @@ public function getDateFormat() */ public function setDateFormat(string $date_format) { + if (is_null($date_format)) { + throw new InvalidArgumentException('non-nullable date_format cannot be null'); + } $allowedValues = $this->getDateFormatAllowableValues(); if (!in_array($date_format, $allowedValues, true)) { throw new InvalidArgumentException( @@ -297,12 +374,10 @@ public function setDateFormat(string $date_format) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -310,7 +385,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -323,13 +398,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -341,12 +414,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -355,8 +426,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubFormFieldGroup.php b/sdks/php/src/Model/SubFormFieldGroup.php index 2982638e8..2ff53e101 100644 --- a/sdks/php/src/Model/SubFormFieldGroup.php +++ b/sdks/php/src/Model/SubFormFieldGroup.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * SubFormFieldGroup Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubFormFieldGroup implements ModelInterface, ArrayAccess, JsonSerializable { @@ -78,6 +75,24 @@ class SubFormFieldGroup implements ModelInterface, ArrayAccess, JsonSerializable 'requirement' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'group_id' => false, + 'group_label' => false, + 'requirement' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -98,6 +113,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -176,39 +235,57 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['group_id'] = $data['group_id'] ?? null; - $this->container['group_label'] = $data['group_label'] ?? null; - $this->container['requirement'] = $data['requirement'] ?? null; + $this->setIfExists('group_id', $data ?? [], null); + $this->setIfExists('group_label', $data ?? [], null); + $this->setIfExists('requirement', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubFormFieldGroup { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubFormFieldGroup { - /** @var SubFormFieldGroup $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubFormFieldGroup */ + return ObjectSerializer::deserialize( $data, SubFormFieldGroup::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -229,7 +306,6 @@ public function listInvalidProperties() if ($this->container['requirement'] === null) { $invalidProperties[] = "'requirement' can't be null"; } - return $invalidProperties; } @@ -263,6 +339,9 @@ public function getGroupId() */ public function setGroupId(string $group_id) { + if (is_null($group_id)) { + throw new InvalidArgumentException('non-nullable group_id cannot be null'); + } $this->container['group_id'] = $group_id; return $this; @@ -287,6 +366,9 @@ public function getGroupLabel() */ public function setGroupLabel(string $group_label) { + if (is_null($group_label)) { + throw new InvalidArgumentException('non-nullable group_label cannot be null'); + } $this->container['group_label'] = $group_label; return $this; @@ -311,6 +393,9 @@ public function getRequirement() */ public function setRequirement(string $requirement) { + if (is_null($requirement)) { + throw new InvalidArgumentException('non-nullable requirement cannot be null'); + } $this->container['requirement'] = $requirement; return $this; @@ -319,12 +404,10 @@ public function setRequirement(string $requirement) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -332,7 +415,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -345,13 +428,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -363,12 +444,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -377,8 +456,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubFormFieldRule.php b/sdks/php/src/Model/SubFormFieldRule.php index 06adccf64..094d8217c 100644 --- a/sdks/php/src/Model/SubFormFieldRule.php +++ b/sdks/php/src/Model/SubFormFieldRule.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -38,11 +37,8 @@ * SubFormFieldRule Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubFormFieldRule implements ModelInterface, ArrayAccess, JsonSerializable { @@ -81,6 +77,25 @@ class SubFormFieldRule implements ModelInterface, ArrayAccess, JsonSerializable 'actions' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'trigger_operator' => false, + 'triggers' => false, + 'actions' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -101,6 +116,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -182,40 +241,58 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['id'] = $data['id'] ?? null; - $this->container['trigger_operator'] = $data['trigger_operator'] ?? 'AND'; - $this->container['triggers'] = $data['triggers'] ?? null; - $this->container['actions'] = $data['actions'] ?? null; + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('trigger_operator', $data ?? [], 'AND'); + $this->setIfExists('triggers', $data ?? [], null); + $this->setIfExists('actions', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubFormFieldRule { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubFormFieldRule { - /** @var SubFormFieldRule $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubFormFieldRule */ + return ObjectSerializer::deserialize( $data, SubFormFieldRule::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -236,18 +313,18 @@ public function listInvalidProperties() if ($this->container['triggers'] === null) { $invalidProperties[] = "'triggers' can't be null"; } - if ((count($this->container['triggers']) > 1)) { + if (count($this->container['triggers']) > 1) { $invalidProperties[] = "invalid value for 'triggers', number of items must be less than or equal to 1."; } - if ((count($this->container['triggers']) < 1)) { + if (count($this->container['triggers']) < 1) { $invalidProperties[] = "invalid value for 'triggers', number of items must be greater than or equal to 1."; } if ($this->container['actions'] === null) { $invalidProperties[] = "'actions' can't be null"; } - if ((count($this->container['actions']) < 1)) { + if (count($this->container['actions']) < 1) { $invalidProperties[] = "invalid value for 'actions', number of items must be greater than or equal to 1."; } @@ -284,6 +361,9 @@ public function getId() */ public function setId(string $id) { + if (is_null($id)) { + throw new InvalidArgumentException('non-nullable id cannot be null'); + } $this->container['id'] = $id; return $this; @@ -308,6 +388,9 @@ public function getTriggerOperator() */ public function setTriggerOperator(string $trigger_operator) { + if (is_null($trigger_operator)) { + throw new InvalidArgumentException('non-nullable trigger_operator cannot be null'); + } $this->container['trigger_operator'] = $trigger_operator; return $this; @@ -332,10 +415,14 @@ public function getTriggers() */ public function setTriggers(array $triggers) { - if ((count($triggers) > 1)) { + if (is_null($triggers)) { + throw new InvalidArgumentException('non-nullable triggers cannot be null'); + } + + if (count($triggers) > 1) { throw new InvalidArgumentException('invalid value for $triggers when calling SubFormFieldRule., number of items must be less than or equal to 1.'); } - if ((count($triggers) < 1)) { + if (count($triggers) < 1) { throw new InvalidArgumentException('invalid length for $triggers when calling SubFormFieldRule., number of items must be greater than or equal to 1.'); } $this->container['triggers'] = $triggers; @@ -362,7 +449,11 @@ public function getActions() */ public function setActions(array $actions) { - if ((count($actions) < 1)) { + if (is_null($actions)) { + throw new InvalidArgumentException('non-nullable actions cannot be null'); + } + + if (count($actions) < 1) { throw new InvalidArgumentException('invalid length for $actions when calling SubFormFieldRule., number of items must be greater than or equal to 1.'); } $this->container['actions'] = $actions; @@ -373,12 +464,10 @@ public function setActions(array $actions) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -386,7 +475,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -399,13 +488,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -417,12 +504,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -431,8 +516,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubFormFieldRuleAction.php b/sdks/php/src/Model/SubFormFieldRuleAction.php index c1802e157..458b5822f 100644 --- a/sdks/php/src/Model/SubFormFieldRuleAction.php +++ b/sdks/php/src/Model/SubFormFieldRuleAction.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -38,11 +37,8 @@ * SubFormFieldRuleAction Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubFormFieldRuleAction implements ModelInterface, ArrayAccess, JsonSerializable { @@ -81,6 +77,25 @@ class SubFormFieldRuleAction implements ModelInterface, ArrayAccess, JsonSeriali 'group_id' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'hidden' => false, + 'type' => false, + 'field_id' => false, + 'group_id' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -101,6 +116,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -198,40 +257,58 @@ public function getTypeAllowableValues() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['hidden'] = $data['hidden'] ?? null; - $this->container['type'] = $data['type'] ?? null; - $this->container['field_id'] = $data['field_id'] ?? null; - $this->container['group_id'] = $data['group_id'] ?? null; + $this->setIfExists('hidden', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('field_id', $data ?? [], null); + $this->setIfExists('group_id', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubFormFieldRuleAction { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubFormFieldRuleAction { - /** @var SubFormFieldRuleAction $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubFormFieldRuleAction */ + return ObjectSerializer::deserialize( $data, SubFormFieldRuleAction::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -291,6 +368,9 @@ public function getHidden() */ public function setHidden(bool $hidden) { + if (is_null($hidden)) { + throw new InvalidArgumentException('non-nullable hidden cannot be null'); + } $this->container['hidden'] = $hidden; return $this; @@ -315,6 +395,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $allowedValues = $this->getTypeAllowableValues(); if (!in_array($type, $allowedValues, true)) { throw new InvalidArgumentException( @@ -349,6 +432,9 @@ public function getFieldId() */ public function setFieldId(?string $field_id) { + if (is_null($field_id)) { + throw new InvalidArgumentException('non-nullable field_id cannot be null'); + } $this->container['field_id'] = $field_id; return $this; @@ -373,6 +459,9 @@ public function getGroupId() */ public function setGroupId(?string $group_id) { + if (is_null($group_id)) { + throw new InvalidArgumentException('non-nullable group_id cannot be null'); + } $this->container['group_id'] = $group_id; return $this; @@ -381,12 +470,10 @@ public function setGroupId(?string $group_id) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -394,7 +481,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -407,13 +494,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -425,12 +510,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -439,8 +522,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubFormFieldRuleTrigger.php b/sdks/php/src/Model/SubFormFieldRuleTrigger.php index 1fbabd217..0ab5768e0 100644 --- a/sdks/php/src/Model/SubFormFieldRuleTrigger.php +++ b/sdks/php/src/Model/SubFormFieldRuleTrigger.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -38,11 +37,8 @@ * SubFormFieldRuleTrigger Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubFormFieldRuleTrigger implements ModelInterface, ArrayAccess, JsonSerializable { @@ -81,6 +77,25 @@ class SubFormFieldRuleTrigger implements ModelInterface, ArrayAccess, JsonSerial 'values' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'operator' => false, + 'value' => false, + 'values' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -101,6 +116,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -204,40 +263,58 @@ public function getOperatorAllowableValues() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['id'] = $data['id'] ?? null; - $this->container['operator'] = $data['operator'] ?? null; - $this->container['value'] = $data['value'] ?? null; - $this->container['values'] = $data['values'] ?? null; + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('operator', $data ?? [], null); + $this->setIfExists('value', $data ?? [], null); + $this->setIfExists('values', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubFormFieldRuleTrigger { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubFormFieldRuleTrigger { - /** @var SubFormFieldRuleTrigger $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubFormFieldRuleTrigger */ + return ObjectSerializer::deserialize( $data, SubFormFieldRuleTrigger::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -297,6 +374,9 @@ public function getId() */ public function setId(string $id) { + if (is_null($id)) { + throw new InvalidArgumentException('non-nullable id cannot be null'); + } $this->container['id'] = $id; return $this; @@ -321,6 +401,9 @@ public function getOperator() */ public function setOperator(string $operator) { + if (is_null($operator)) { + throw new InvalidArgumentException('non-nullable operator cannot be null'); + } $allowedValues = $this->getOperatorAllowableValues(); if (!in_array($operator, $allowedValues, true)) { throw new InvalidArgumentException( @@ -355,6 +438,9 @@ public function getValue() */ public function setValue(?string $value) { + if (is_null($value)) { + throw new InvalidArgumentException('non-nullable value cannot be null'); + } $this->container['value'] = $value; return $this; @@ -379,6 +465,9 @@ public function getValues() */ public function setValues(?array $values) { + if (is_null($values)) { + throw new InvalidArgumentException('non-nullable values cannot be null'); + } $this->container['values'] = $values; return $this; @@ -387,12 +476,10 @@ public function setValues(?array $values) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -400,7 +487,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -413,13 +500,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -431,12 +516,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -445,8 +528,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubFormFieldsPerDocumentBase.php b/sdks/php/src/Model/SubFormFieldsPerDocumentBase.php index 273b7e238..68158bf5a 100644 --- a/sdks/php/src/Model/SubFormFieldsPerDocumentBase.php +++ b/sdks/php/src/Model/SubFormFieldsPerDocumentBase.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,14 +38,10 @@ * * @category Class * @description The fields that should appear on the document, expressed as an array of objects. (For more details you can read about it here: [Using Form Fields per Document](/docs/openapi/form-fields-per-document).) **NOTE:** Fields like **text**, **dropdown**, **checkbox**, **radio**, and **hyperlink** have additional required and optional parameters. Check out the list of [additional parameters](/api/reference/constants/#form-fields-per-document) for these field types. * Text Field use `SubFormFieldsPerDocumentText` * Dropdown Field use `SubFormFieldsPerDocumentDropdown` * Hyperlink Field use `SubFormFieldsPerDocumentHyperlink` * Checkbox Field use `SubFormFieldsPerDocumentCheckbox` * Radio Field use `SubFormFieldsPerDocumentRadio` * Signature Field use `SubFormFieldsPerDocumentSignature` * Date Signed Field use `SubFormFieldsPerDocumentDateSigned` * Initials Field use `SubFormFieldsPerDocumentInitials` * Text Merge Field use `SubFormFieldsPerDocumentTextMerge` * Checkbox Merge Field use `SubFormFieldsPerDocumentCheckboxMerge` - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ -abstract class SubFormFieldsPerDocumentBase implements ModelInterface, ArrayAccess, JsonSerializable +class SubFormFieldsPerDocumentBase implements ModelInterface, ArrayAccess, JsonSerializable { public const DISCRIMINATOR = 'type'; @@ -96,6 +92,32 @@ abstract class SubFormFieldsPerDocumentBase implements ModelInterface, ArrayAcce 'page' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'document_index' => false, + 'api_id' => false, + 'height' => false, + 'required' => false, + 'signer' => false, + 'type' => false, + 'width' => false, + 'x' => false, + 'y' => false, + 'name' => false, + 'page' => true, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -116,6 +138,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -218,29 +284,29 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['document_index'] = $data['document_index'] ?? null; - $this->container['api_id'] = $data['api_id'] ?? null; - $this->container['height'] = $data['height'] ?? null; - $this->container['required'] = $data['required'] ?? null; - $this->container['signer'] = $data['signer'] ?? null; - $this->container['type'] = $data['type'] ?? null; - $this->container['width'] = $data['width'] ?? null; - $this->container['x'] = $data['x'] ?? null; - $this->container['y'] = $data['y'] ?? null; - $this->container['name'] = $data['name'] ?? null; - $this->container['page'] = $data['page'] ?? null; + $this->setIfExists('document_index', $data ?? [], null); + $this->setIfExists('api_id', $data ?? [], null); + $this->setIfExists('height', $data ?? [], null); + $this->setIfExists('required', $data ?? [], null); + $this->setIfExists('signer', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('width', $data ?? [], null); + $this->setIfExists('x', $data ?? [], null); + $this->setIfExists('y', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('page', $data ?? [], null); // Initialize discriminator property with the model name. $this->container['type'] = static::$openAPIModelName; @@ -286,6 +352,22 @@ public static function discriminatorClassName(array $data): ?string return null; } + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + /** * Show all the invalid properties with reasons. * @@ -322,7 +404,6 @@ public function listInvalidProperties() if ($this->container['y'] === null) { $invalidProperties[] = "'y' can't be null"; } - return $invalidProperties; } @@ -356,6 +437,9 @@ public function getDocumentIndex() */ public function setDocumentIndex(int $document_index) { + if (is_null($document_index)) { + throw new InvalidArgumentException('non-nullable document_index cannot be null'); + } $this->container['document_index'] = $document_index; return $this; @@ -380,6 +464,9 @@ public function getApiId() */ public function setApiId(string $api_id) { + if (is_null($api_id)) { + throw new InvalidArgumentException('non-nullable api_id cannot be null'); + } $this->container['api_id'] = $api_id; return $this; @@ -404,6 +491,9 @@ public function getHeight() */ public function setHeight(int $height) { + if (is_null($height)) { + throw new InvalidArgumentException('non-nullable height cannot be null'); + } $this->container['height'] = $height; return $this; @@ -428,6 +518,9 @@ public function getRequired() */ public function setRequired(bool $required) { + if (is_null($required)) { + throw new InvalidArgumentException('non-nullable required cannot be null'); + } $this->container['required'] = $required; return $this; @@ -436,7 +529,7 @@ public function setRequired(bool $required) /** * Gets signer * - * @return int|string + * @return string */ public function getSigner() { @@ -446,12 +539,15 @@ public function getSigner() /** * Sets signer * - * @param int|string $signer Signer index identified by the offset in the signers parameter (0-based indexing), indicating which signer should fill out the field. **NOTE:** To set the value of the field as the preparer you must set this to `me_now` **NOTE:** If type is `text-merge` or `checkbox-merge`, you must set this to sender in order to use pre-filled data. + * @param string $signer Signer index identified by the offset in the signers parameter (0-based indexing), indicating which signer should fill out the field. **NOTE:** To set the value of the field as the preparer you must set this to `me_now` **NOTE:** If type is `text-merge` or `checkbox-merge`, you must set this to sender in order to use pre-filled data. * * @return self */ - public function setSigner($signer) + public function setSigner(string $signer) { + if (is_null($signer)) { + throw new InvalidArgumentException('non-nullable signer cannot be null'); + } $this->container['signer'] = $signer; return $this; @@ -476,6 +572,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -500,6 +599,9 @@ public function getWidth() */ public function setWidth(int $width) { + if (is_null($width)) { + throw new InvalidArgumentException('non-nullable width cannot be null'); + } $this->container['width'] = $width; return $this; @@ -524,6 +626,9 @@ public function getX() */ public function setX(int $x) { + if (is_null($x)) { + throw new InvalidArgumentException('non-nullable x cannot be null'); + } $this->container['x'] = $x; return $this; @@ -548,6 +653,9 @@ public function getY() */ public function setY(int $y) { + if (is_null($y)) { + throw new InvalidArgumentException('non-nullable y cannot be null'); + } $this->container['y'] = $y; return $this; @@ -572,6 +680,9 @@ public function getName() */ public function setName(?string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -596,6 +707,16 @@ public function getPage() */ public function setPage(?int $page) { + if (is_null($page)) { + array_push($this->openAPINullablesSetToNull, 'page'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('page', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['page'] = $page; return $this; @@ -604,12 +725,10 @@ public function setPage(?int $page) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -617,7 +736,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -630,13 +749,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -648,12 +765,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -662,8 +777,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubFormFieldsPerDocumentCheckbox.php b/sdks/php/src/Model/SubFormFieldsPerDocumentCheckbox.php index 73b035443..c023916c7 100644 --- a/sdks/php/src/Model/SubFormFieldsPerDocumentCheckbox.php +++ b/sdks/php/src/Model/SubFormFieldsPerDocumentCheckbox.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,6 +28,7 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** @@ -36,11 +36,8 @@ * * @category Class * @description This class extends `SubFormFieldsPerDocumentBase`. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubFormFieldsPerDocumentCheckbox extends SubFormFieldsPerDocumentBase { @@ -77,6 +74,24 @@ class SubFormFieldsPerDocumentCheckbox extends SubFormFieldsPerDocumentBase 'group' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'is_checked' => false, + 'group' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -97,6 +112,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -175,34 +234,52 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'checkbox'; - $this->container['is_checked'] = $data['is_checked'] ?? null; - $this->container['group'] = $data['group'] ?? null; + $this->setIfExists('type', $data ?? [], 'checkbox'); + $this->setIfExists('is_checked', $data ?? [], null); + $this->setIfExists('group', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubFormFieldsPerDocumentCheckbox { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubFormFieldsPerDocumentCheckbox { - /** @var SubFormFieldsPerDocumentCheckbox $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubFormFieldsPerDocumentCheckbox */ + return ObjectSerializer::deserialize( $data, SubFormFieldsPerDocumentCheckbox::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -220,7 +297,6 @@ public function listInvalidProperties() if ($this->container['is_checked'] === null) { $invalidProperties[] = "'is_checked' can't be null"; } - return $invalidProperties; } @@ -254,6 +330,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -278,6 +357,9 @@ public function getIsChecked() */ public function setIsChecked(bool $is_checked) { + if (is_null($is_checked)) { + throw new InvalidArgumentException('non-nullable is_checked cannot be null'); + } $this->container['is_checked'] = $is_checked; return $this; @@ -302,6 +384,9 @@ public function getGroup() */ public function setGroup(?string $group) { + if (is_null($group)) { + throw new InvalidArgumentException('non-nullable group cannot be null'); + } $this->container['group'] = $group; return $this; @@ -310,12 +395,10 @@ public function setGroup(?string $group) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -323,7 +406,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -336,13 +419,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -354,12 +435,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -368,8 +447,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubFormFieldsPerDocumentCheckboxMerge.php b/sdks/php/src/Model/SubFormFieldsPerDocumentCheckboxMerge.php index 7c2add6a2..c3924079b 100644 --- a/sdks/php/src/Model/SubFormFieldsPerDocumentCheckboxMerge.php +++ b/sdks/php/src/Model/SubFormFieldsPerDocumentCheckboxMerge.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,6 +28,7 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** @@ -36,11 +36,8 @@ * * @category Class * @description This class extends `SubFormFieldsPerDocumentBase`. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubFormFieldsPerDocumentCheckboxMerge extends SubFormFieldsPerDocumentBase { @@ -73,6 +70,22 @@ class SubFormFieldsPerDocumentCheckboxMerge extends SubFormFieldsPerDocumentBase 'type' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -93,6 +106,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -165,32 +222,50 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'checkbox-merge'; + $this->setIfExists('type', $data ?? [], 'checkbox-merge'); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubFormFieldsPerDocumentCheckboxMerge { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubFormFieldsPerDocumentCheckboxMerge { - /** @var SubFormFieldsPerDocumentCheckboxMerge $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubFormFieldsPerDocumentCheckboxMerge */ + return ObjectSerializer::deserialize( $data, SubFormFieldsPerDocumentCheckboxMerge::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -205,7 +280,6 @@ public function listInvalidProperties() if ($this->container['type'] === null) { $invalidProperties[] = "'type' can't be null"; } - return $invalidProperties; } @@ -239,6 +313,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -247,12 +324,10 @@ public function setType(string $type) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -260,7 +335,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -273,13 +348,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -291,12 +364,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -305,8 +376,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubFormFieldsPerDocumentDateSigned.php b/sdks/php/src/Model/SubFormFieldsPerDocumentDateSigned.php index 22f989b9d..5902025ad 100644 --- a/sdks/php/src/Model/SubFormFieldsPerDocumentDateSigned.php +++ b/sdks/php/src/Model/SubFormFieldsPerDocumentDateSigned.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -37,11 +36,8 @@ * * @category Class * @description This class extends `SubFormFieldsPerDocumentBase`. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubFormFieldsPerDocumentDateSigned extends SubFormFieldsPerDocumentBase { @@ -78,6 +74,24 @@ class SubFormFieldsPerDocumentDateSigned extends SubFormFieldsPerDocumentBase 'font_size' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'font_family' => false, + 'font_size' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -98,6 +112,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -220,34 +278,52 @@ public function getFontFamilyAllowableValues() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'date_signed'; - $this->container['font_family'] = $data['font_family'] ?? null; - $this->container['font_size'] = $data['font_size'] ?? 12; + $this->setIfExists('type', $data ?? [], 'date_signed'); + $this->setIfExists('font_family', $data ?? [], null); + $this->setIfExists('font_size', $data ?? [], 12); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubFormFieldsPerDocumentDateSigned { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubFormFieldsPerDocumentDateSigned { - /** @var SubFormFieldsPerDocumentDateSigned $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubFormFieldsPerDocumentDateSigned */ + return ObjectSerializer::deserialize( $data, SubFormFieldsPerDocumentDateSigned::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -304,6 +380,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -328,8 +407,11 @@ public function getFontFamily() */ public function setFontFamily(?string $font_family) { + if (is_null($font_family)) { + throw new InvalidArgumentException('non-nullable font_family cannot be null'); + } $allowedValues = $this->getFontFamilyAllowableValues(); - if (!is_null($font_family) && !in_array($font_family, $allowedValues, true)) { + if (!in_array($font_family, $allowedValues, true)) { throw new InvalidArgumentException( sprintf( "Invalid value '%s' for 'font_family', must be one of '%s'", @@ -362,6 +444,9 @@ public function getFontSize() */ public function setFontSize(?int $font_size) { + if (is_null($font_size)) { + throw new InvalidArgumentException('non-nullable font_size cannot be null'); + } $this->container['font_size'] = $font_size; return $this; @@ -370,12 +455,10 @@ public function setFontSize(?int $font_size) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -383,7 +466,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -396,13 +479,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -414,12 +495,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -428,8 +507,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubFormFieldsPerDocumentDropdown.php b/sdks/php/src/Model/SubFormFieldsPerDocumentDropdown.php index f4b1cb5bd..121c3eb48 100644 --- a/sdks/php/src/Model/SubFormFieldsPerDocumentDropdown.php +++ b/sdks/php/src/Model/SubFormFieldsPerDocumentDropdown.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -37,11 +36,8 @@ * * @category Class * @description This class extends `SubFormFieldsPerDocumentBase`. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubFormFieldsPerDocumentDropdown extends SubFormFieldsPerDocumentBase { @@ -82,6 +78,26 @@ class SubFormFieldsPerDocumentDropdown extends SubFormFieldsPerDocumentBase 'font_size' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'options' => false, + 'content' => false, + 'font_family' => false, + 'font_size' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -102,6 +118,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -230,36 +290,54 @@ public function getFontFamilyAllowableValues() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'dropdown'; - $this->container['options'] = $data['options'] ?? null; - $this->container['content'] = $data['content'] ?? null; - $this->container['font_family'] = $data['font_family'] ?? null; - $this->container['font_size'] = $data['font_size'] ?? 12; + $this->setIfExists('type', $data ?? [], 'dropdown'); + $this->setIfExists('options', $data ?? [], null); + $this->setIfExists('content', $data ?? [], null); + $this->setIfExists('font_family', $data ?? [], null); + $this->setIfExists('font_size', $data ?? [], 12); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubFormFieldsPerDocumentDropdown { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubFormFieldsPerDocumentDropdown { - /** @var SubFormFieldsPerDocumentDropdown $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubFormFieldsPerDocumentDropdown */ + return ObjectSerializer::deserialize( $data, SubFormFieldsPerDocumentDropdown::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -277,7 +355,7 @@ public function listInvalidProperties() if ($this->container['options'] === null) { $invalidProperties[] = "'options' can't be null"; } - if ((count($this->container['options']) < 1)) { + if (count($this->container['options']) < 1) { $invalidProperties[] = "invalid value for 'options', number of items must be greater than or equal to 1."; } @@ -323,6 +401,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -347,7 +428,11 @@ public function getOptions() */ public function setOptions(array $options) { - if ((count($options) < 1)) { + if (is_null($options)) { + throw new InvalidArgumentException('non-nullable options cannot be null'); + } + + if (count($options) < 1) { throw new InvalidArgumentException('invalid length for $options when calling SubFormFieldsPerDocumentDropdown., number of items must be greater than or equal to 1.'); } $this->container['options'] = $options; @@ -374,6 +459,9 @@ public function getContent() */ public function setContent(?string $content) { + if (is_null($content)) { + throw new InvalidArgumentException('non-nullable content cannot be null'); + } $this->container['content'] = $content; return $this; @@ -398,8 +486,11 @@ public function getFontFamily() */ public function setFontFamily(?string $font_family) { + if (is_null($font_family)) { + throw new InvalidArgumentException('non-nullable font_family cannot be null'); + } $allowedValues = $this->getFontFamilyAllowableValues(); - if (!is_null($font_family) && !in_array($font_family, $allowedValues, true)) { + if (!in_array($font_family, $allowedValues, true)) { throw new InvalidArgumentException( sprintf( "Invalid value '%s' for 'font_family', must be one of '%s'", @@ -432,6 +523,9 @@ public function getFontSize() */ public function setFontSize(?int $font_size) { + if (is_null($font_size)) { + throw new InvalidArgumentException('non-nullable font_size cannot be null'); + } $this->container['font_size'] = $font_size; return $this; @@ -440,12 +534,10 @@ public function setFontSize(?int $font_size) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -453,7 +545,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -466,13 +558,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -484,12 +574,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -498,8 +586,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubFormFieldsPerDocumentFontEnum.php b/sdks/php/src/Model/SubFormFieldsPerDocumentFontEnum.php index 6880c6dac..bc0eff196 100644 --- a/sdks/php/src/Model/SubFormFieldsPerDocumentFontEnum.php +++ b/sdks/php/src/Model/SubFormFieldsPerDocumentFontEnum.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -32,7 +31,6 @@ * SubFormFieldsPerDocumentFontEnum Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ class SubFormFieldsPerDocumentFontEnum diff --git a/sdks/php/src/Model/SubFormFieldsPerDocumentHyperlink.php b/sdks/php/src/Model/SubFormFieldsPerDocumentHyperlink.php index 7a9b19714..924429f26 100644 --- a/sdks/php/src/Model/SubFormFieldsPerDocumentHyperlink.php +++ b/sdks/php/src/Model/SubFormFieldsPerDocumentHyperlink.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -37,11 +36,8 @@ * * @category Class * @description This class extends `SubFormFieldsPerDocumentBase`. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubFormFieldsPerDocumentHyperlink extends SubFormFieldsPerDocumentBase { @@ -82,6 +78,26 @@ class SubFormFieldsPerDocumentHyperlink extends SubFormFieldsPerDocumentBase 'font_size' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'content' => false, + 'content_url' => false, + 'font_family' => false, + 'font_size' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -102,6 +118,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -230,36 +290,54 @@ public function getFontFamilyAllowableValues() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'hyperlink'; - $this->container['content'] = $data['content'] ?? null; - $this->container['content_url'] = $data['content_url'] ?? null; - $this->container['font_family'] = $data['font_family'] ?? null; - $this->container['font_size'] = $data['font_size'] ?? 12; + $this->setIfExists('type', $data ?? [], 'hyperlink'); + $this->setIfExists('content', $data ?? [], null); + $this->setIfExists('content_url', $data ?? [], null); + $this->setIfExists('font_family', $data ?? [], null); + $this->setIfExists('font_size', $data ?? [], 12); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubFormFieldsPerDocumentHyperlink { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubFormFieldsPerDocumentHyperlink { - /** @var SubFormFieldsPerDocumentHyperlink $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubFormFieldsPerDocumentHyperlink */ + return ObjectSerializer::deserialize( $data, SubFormFieldsPerDocumentHyperlink::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -322,6 +400,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -346,6 +427,9 @@ public function getContent() */ public function setContent(string $content) { + if (is_null($content)) { + throw new InvalidArgumentException('non-nullable content cannot be null'); + } $this->container['content'] = $content; return $this; @@ -370,6 +454,9 @@ public function getContentUrl() */ public function setContentUrl(string $content_url) { + if (is_null($content_url)) { + throw new InvalidArgumentException('non-nullable content_url cannot be null'); + } $this->container['content_url'] = $content_url; return $this; @@ -394,8 +481,11 @@ public function getFontFamily() */ public function setFontFamily(?string $font_family) { + if (is_null($font_family)) { + throw new InvalidArgumentException('non-nullable font_family cannot be null'); + } $allowedValues = $this->getFontFamilyAllowableValues(); - if (!is_null($font_family) && !in_array($font_family, $allowedValues, true)) { + if (!in_array($font_family, $allowedValues, true)) { throw new InvalidArgumentException( sprintf( "Invalid value '%s' for 'font_family', must be one of '%s'", @@ -428,6 +518,9 @@ public function getFontSize() */ public function setFontSize(?int $font_size) { + if (is_null($font_size)) { + throw new InvalidArgumentException('non-nullable font_size cannot be null'); + } $this->container['font_size'] = $font_size; return $this; @@ -436,12 +529,10 @@ public function setFontSize(?int $font_size) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -449,7 +540,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -462,13 +553,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -480,12 +569,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -494,8 +581,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubFormFieldsPerDocumentInitials.php b/sdks/php/src/Model/SubFormFieldsPerDocumentInitials.php index c13441367..cfddb0495 100644 --- a/sdks/php/src/Model/SubFormFieldsPerDocumentInitials.php +++ b/sdks/php/src/Model/SubFormFieldsPerDocumentInitials.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,6 +28,7 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** @@ -36,11 +36,8 @@ * * @category Class * @description This class extends `SubFormFieldsPerDocumentBase`. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubFormFieldsPerDocumentInitials extends SubFormFieldsPerDocumentBase { @@ -73,6 +70,22 @@ class SubFormFieldsPerDocumentInitials extends SubFormFieldsPerDocumentBase 'type' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -93,6 +106,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -165,32 +222,50 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'initials'; + $this->setIfExists('type', $data ?? [], 'initials'); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubFormFieldsPerDocumentInitials { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubFormFieldsPerDocumentInitials { - /** @var SubFormFieldsPerDocumentInitials $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubFormFieldsPerDocumentInitials */ + return ObjectSerializer::deserialize( $data, SubFormFieldsPerDocumentInitials::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -205,7 +280,6 @@ public function listInvalidProperties() if ($this->container['type'] === null) { $invalidProperties[] = "'type' can't be null"; } - return $invalidProperties; } @@ -239,6 +313,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -247,12 +324,10 @@ public function setType(string $type) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -260,7 +335,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -273,13 +348,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -291,12 +364,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -305,8 +376,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubFormFieldsPerDocumentRadio.php b/sdks/php/src/Model/SubFormFieldsPerDocumentRadio.php index 62c9fa4e8..b506baa56 100644 --- a/sdks/php/src/Model/SubFormFieldsPerDocumentRadio.php +++ b/sdks/php/src/Model/SubFormFieldsPerDocumentRadio.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,6 +28,7 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** @@ -36,11 +36,8 @@ * * @category Class * @description This class extends `SubFormFieldsPerDocumentBase`. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubFormFieldsPerDocumentRadio extends SubFormFieldsPerDocumentBase { @@ -77,6 +74,24 @@ class SubFormFieldsPerDocumentRadio extends SubFormFieldsPerDocumentBase 'is_checked' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'group' => false, + 'is_checked' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -97,6 +112,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -175,34 +234,52 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'radio'; - $this->container['group'] = $data['group'] ?? null; - $this->container['is_checked'] = $data['is_checked'] ?? null; + $this->setIfExists('type', $data ?? [], 'radio'); + $this->setIfExists('group', $data ?? [], null); + $this->setIfExists('is_checked', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubFormFieldsPerDocumentRadio { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubFormFieldsPerDocumentRadio { - /** @var SubFormFieldsPerDocumentRadio $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubFormFieldsPerDocumentRadio */ + return ObjectSerializer::deserialize( $data, SubFormFieldsPerDocumentRadio::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -223,7 +300,6 @@ public function listInvalidProperties() if ($this->container['is_checked'] === null) { $invalidProperties[] = "'is_checked' can't be null"; } - return $invalidProperties; } @@ -257,6 +333,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -281,6 +360,9 @@ public function getGroup() */ public function setGroup(string $group) { + if (is_null($group)) { + throw new InvalidArgumentException('non-nullable group cannot be null'); + } $this->container['group'] = $group; return $this; @@ -305,6 +387,9 @@ public function getIsChecked() */ public function setIsChecked(bool $is_checked) { + if (is_null($is_checked)) { + throw new InvalidArgumentException('non-nullable is_checked cannot be null'); + } $this->container['is_checked'] = $is_checked; return $this; @@ -313,12 +398,10 @@ public function setIsChecked(bool $is_checked) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -326,7 +409,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -339,13 +422,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -357,12 +438,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -371,8 +450,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubFormFieldsPerDocumentSignature.php b/sdks/php/src/Model/SubFormFieldsPerDocumentSignature.php index 08df4c6e3..37c6e7a15 100644 --- a/sdks/php/src/Model/SubFormFieldsPerDocumentSignature.php +++ b/sdks/php/src/Model/SubFormFieldsPerDocumentSignature.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,6 +28,7 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** @@ -36,11 +36,8 @@ * * @category Class * @description This class extends `SubFormFieldsPerDocumentBase`. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubFormFieldsPerDocumentSignature extends SubFormFieldsPerDocumentBase { @@ -73,6 +70,22 @@ class SubFormFieldsPerDocumentSignature extends SubFormFieldsPerDocumentBase 'type' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -93,6 +106,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -165,32 +222,50 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'signature'; + $this->setIfExists('type', $data ?? [], 'signature'); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubFormFieldsPerDocumentSignature { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubFormFieldsPerDocumentSignature { - /** @var SubFormFieldsPerDocumentSignature $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubFormFieldsPerDocumentSignature */ + return ObjectSerializer::deserialize( $data, SubFormFieldsPerDocumentSignature::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -205,7 +280,6 @@ public function listInvalidProperties() if ($this->container['type'] === null) { $invalidProperties[] = "'type' can't be null"; } - return $invalidProperties; } @@ -239,6 +313,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -247,12 +324,10 @@ public function setType(string $type) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -260,7 +335,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -273,13 +348,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -291,12 +364,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -305,8 +376,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubFormFieldsPerDocumentText.php b/sdks/php/src/Model/SubFormFieldsPerDocumentText.php index 09ceea997..fa048a12b 100644 --- a/sdks/php/src/Model/SubFormFieldsPerDocumentText.php +++ b/sdks/php/src/Model/SubFormFieldsPerDocumentText.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -37,11 +36,8 @@ * * @category Class * @description This class extends `SubFormFieldsPerDocumentBase`. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubFormFieldsPerDocumentText extends SubFormFieldsPerDocumentBase { @@ -94,6 +90,32 @@ class SubFormFieldsPerDocumentText extends SubFormFieldsPerDocumentBase 'font_size' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'placeholder' => false, + 'auto_fill_type' => false, + 'link_id' => false, + 'masked' => false, + 'validation_type' => false, + 'validation_custom_regex' => false, + 'validation_custom_regex_format_label' => false, + 'content' => false, + 'font_family' => false, + 'font_size' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -114,6 +136,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -291,42 +357,60 @@ public function getFontFamilyAllowableValues() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'text'; - $this->container['placeholder'] = $data['placeholder'] ?? null; - $this->container['auto_fill_type'] = $data['auto_fill_type'] ?? null; - $this->container['link_id'] = $data['link_id'] ?? null; - $this->container['masked'] = $data['masked'] ?? null; - $this->container['validation_type'] = $data['validation_type'] ?? null; - $this->container['validation_custom_regex'] = $data['validation_custom_regex'] ?? null; - $this->container['validation_custom_regex_format_label'] = $data['validation_custom_regex_format_label'] ?? null; - $this->container['content'] = $data['content'] ?? null; - $this->container['font_family'] = $data['font_family'] ?? null; - $this->container['font_size'] = $data['font_size'] ?? 12; + $this->setIfExists('type', $data ?? [], 'text'); + $this->setIfExists('placeholder', $data ?? [], null); + $this->setIfExists('auto_fill_type', $data ?? [], null); + $this->setIfExists('link_id', $data ?? [], null); + $this->setIfExists('masked', $data ?? [], null); + $this->setIfExists('validation_type', $data ?? [], null); + $this->setIfExists('validation_custom_regex', $data ?? [], null); + $this->setIfExists('validation_custom_regex_format_label', $data ?? [], null); + $this->setIfExists('content', $data ?? [], null); + $this->setIfExists('font_family', $data ?? [], null); + $this->setIfExists('font_size', $data ?? [], 12); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubFormFieldsPerDocumentText { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubFormFieldsPerDocumentText { - /** @var SubFormFieldsPerDocumentText $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubFormFieldsPerDocumentText */ + return ObjectSerializer::deserialize( $data, SubFormFieldsPerDocumentText::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -392,6 +476,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -416,6 +503,9 @@ public function getPlaceholder() */ public function setPlaceholder(?string $placeholder) { + if (is_null($placeholder)) { + throw new InvalidArgumentException('non-nullable placeholder cannot be null'); + } $this->container['placeholder'] = $placeholder; return $this; @@ -440,6 +530,9 @@ public function getAutoFillType() */ public function setAutoFillType(?string $auto_fill_type) { + if (is_null($auto_fill_type)) { + throw new InvalidArgumentException('non-nullable auto_fill_type cannot be null'); + } $this->container['auto_fill_type'] = $auto_fill_type; return $this; @@ -464,6 +557,9 @@ public function getLinkId() */ public function setLinkId(?string $link_id) { + if (is_null($link_id)) { + throw new InvalidArgumentException('non-nullable link_id cannot be null'); + } $this->container['link_id'] = $link_id; return $this; @@ -488,6 +584,9 @@ public function getMasked() */ public function setMasked(?bool $masked) { + if (is_null($masked)) { + throw new InvalidArgumentException('non-nullable masked cannot be null'); + } $this->container['masked'] = $masked; return $this; @@ -512,8 +611,11 @@ public function getValidationType() */ public function setValidationType(?string $validation_type) { + if (is_null($validation_type)) { + throw new InvalidArgumentException('non-nullable validation_type cannot be null'); + } $allowedValues = $this->getValidationTypeAllowableValues(); - if (!is_null($validation_type) && !in_array($validation_type, $allowedValues, true)) { + if (!in_array($validation_type, $allowedValues, true)) { throw new InvalidArgumentException( sprintf( "Invalid value '%s' for 'validation_type', must be one of '%s'", @@ -546,6 +648,9 @@ public function getValidationCustomRegex() */ public function setValidationCustomRegex(?string $validation_custom_regex) { + if (is_null($validation_custom_regex)) { + throw new InvalidArgumentException('non-nullable validation_custom_regex cannot be null'); + } $this->container['validation_custom_regex'] = $validation_custom_regex; return $this; @@ -570,6 +675,9 @@ public function getValidationCustomRegexFormatLabel() */ public function setValidationCustomRegexFormatLabel(?string $validation_custom_regex_format_label) { + if (is_null($validation_custom_regex_format_label)) { + throw new InvalidArgumentException('non-nullable validation_custom_regex_format_label cannot be null'); + } $this->container['validation_custom_regex_format_label'] = $validation_custom_regex_format_label; return $this; @@ -594,6 +702,9 @@ public function getContent() */ public function setContent(?string $content) { + if (is_null($content)) { + throw new InvalidArgumentException('non-nullable content cannot be null'); + } $this->container['content'] = $content; return $this; @@ -618,8 +729,11 @@ public function getFontFamily() */ public function setFontFamily(?string $font_family) { + if (is_null($font_family)) { + throw new InvalidArgumentException('non-nullable font_family cannot be null'); + } $allowedValues = $this->getFontFamilyAllowableValues(); - if (!is_null($font_family) && !in_array($font_family, $allowedValues, true)) { + if (!in_array($font_family, $allowedValues, true)) { throw new InvalidArgumentException( sprintf( "Invalid value '%s' for 'font_family', must be one of '%s'", @@ -652,6 +766,9 @@ public function getFontSize() */ public function setFontSize(?int $font_size) { + if (is_null($font_size)) { + throw new InvalidArgumentException('non-nullable font_size cannot be null'); + } $this->container['font_size'] = $font_size; return $this; @@ -660,12 +777,10 @@ public function setFontSize(?int $font_size) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -673,7 +788,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -686,13 +801,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -704,12 +817,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -718,8 +829,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubFormFieldsPerDocumentTextMerge.php b/sdks/php/src/Model/SubFormFieldsPerDocumentTextMerge.php index 08ceb07ec..bfe22420e 100644 --- a/sdks/php/src/Model/SubFormFieldsPerDocumentTextMerge.php +++ b/sdks/php/src/Model/SubFormFieldsPerDocumentTextMerge.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -37,11 +36,8 @@ * * @category Class * @description This class extends `SubFormFieldsPerDocumentBase`. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubFormFieldsPerDocumentTextMerge extends SubFormFieldsPerDocumentBase { @@ -78,6 +74,24 @@ class SubFormFieldsPerDocumentTextMerge extends SubFormFieldsPerDocumentBase 'font_size' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'font_family' => false, + 'font_size' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -98,6 +112,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -220,34 +278,52 @@ public function getFontFamilyAllowableValues() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'text-merge'; - $this->container['font_family'] = $data['font_family'] ?? null; - $this->container['font_size'] = $data['font_size'] ?? 12; + $this->setIfExists('type', $data ?? [], 'text-merge'); + $this->setIfExists('font_family', $data ?? [], null); + $this->setIfExists('font_size', $data ?? [], 12); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubFormFieldsPerDocumentTextMerge { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubFormFieldsPerDocumentTextMerge { - /** @var SubFormFieldsPerDocumentTextMerge $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubFormFieldsPerDocumentTextMerge */ + return ObjectSerializer::deserialize( $data, SubFormFieldsPerDocumentTextMerge::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -304,6 +380,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -328,8 +407,11 @@ public function getFontFamily() */ public function setFontFamily(?string $font_family) { + if (is_null($font_family)) { + throw new InvalidArgumentException('non-nullable font_family cannot be null'); + } $allowedValues = $this->getFontFamilyAllowableValues(); - if (!is_null($font_family) && !in_array($font_family, $allowedValues, true)) { + if (!in_array($font_family, $allowedValues, true)) { throw new InvalidArgumentException( sprintf( "Invalid value '%s' for 'font_family', must be one of '%s'", @@ -362,6 +444,9 @@ public function getFontSize() */ public function setFontSize(?int $font_size) { + if (is_null($font_size)) { + throw new InvalidArgumentException('non-nullable font_size cannot be null'); + } $this->container['font_size'] = $font_size; return $this; @@ -370,12 +455,10 @@ public function setFontSize(?int $font_size) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -383,7 +466,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -396,13 +479,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -414,12 +495,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -428,8 +507,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubFormFieldsPerDocumentTypeEnum.php b/sdks/php/src/Model/SubFormFieldsPerDocumentTypeEnum.php index efe5595e6..4a4294f5e 100644 --- a/sdks/php/src/Model/SubFormFieldsPerDocumentTypeEnum.php +++ b/sdks/php/src/Model/SubFormFieldsPerDocumentTypeEnum.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -32,7 +31,6 @@ * SubFormFieldsPerDocumentTypeEnum Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ class SubFormFieldsPerDocumentTypeEnum diff --git a/sdks/php/src/Model/SubMergeField.php b/sdks/php/src/Model/SubMergeField.php index cbc6ffc78..8631a07e4 100644 --- a/sdks/php/src/Model/SubMergeField.php +++ b/sdks/php/src/Model/SubMergeField.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -38,11 +37,8 @@ * SubMergeField Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubMergeField implements ModelInterface, ArrayAccess, JsonSerializable { @@ -77,6 +73,23 @@ class SubMergeField implements ModelInterface, ArrayAccess, JsonSerializable 'type' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'name' => false, + 'type' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -97,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -188,38 +245,56 @@ public function getTypeAllowableValues() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['name'] = $data['name'] ?? null; - $this->container['type'] = $data['type'] ?? null; + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubMergeField { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubMergeField { - /** @var SubMergeField $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubMergeField */ + return ObjectSerializer::deserialize( $data, SubMergeField::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -279,6 +354,9 @@ public function getName() */ public function setName(string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -303,6 +381,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $allowedValues = $this->getTypeAllowableValues(); if (!in_array($type, $allowedValues, true)) { throw new InvalidArgumentException( @@ -321,12 +402,10 @@ public function setType(string $type) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -334,7 +413,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -347,13 +426,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -365,12 +442,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -379,8 +454,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubOAuth.php b/sdks/php/src/Model/SubOAuth.php index 488da3405..2bbf85547 100644 --- a/sdks/php/src/Model/SubOAuth.php +++ b/sdks/php/src/Model/SubOAuth.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -39,11 +38,8 @@ * * @category Class * @description OAuth related parameters. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubOAuth implements ModelInterface, ArrayAccess, JsonSerializable { @@ -78,6 +74,23 @@ class SubOAuth implements ModelInterface, ArrayAccess, JsonSerializable 'scopes' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'callback_url' => false, + 'scopes' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -98,6 +111,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -201,38 +258,56 @@ public function getScopesAllowableValues() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['callback_url'] = $data['callback_url'] ?? null; - $this->container['scopes'] = $data['scopes'] ?? null; + $this->setIfExists('callback_url', $data ?? [], null); + $this->setIfExists('scopes', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubOAuth { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubOAuth { - /** @var SubOAuth $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubOAuth */ + return ObjectSerializer::deserialize( $data, SubOAuth::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -242,9 +317,7 @@ public static function init(array $data): SubOAuth */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -277,6 +350,9 @@ public function getCallbackUrl() */ public function setCallbackUrl(?string $callback_url) { + if (is_null($callback_url)) { + throw new InvalidArgumentException('non-nullable callback_url cannot be null'); + } $this->container['callback_url'] = $callback_url; return $this; @@ -301,8 +377,11 @@ public function getScopes() */ public function setScopes(?array $scopes) { + if (is_null($scopes)) { + throw new InvalidArgumentException('non-nullable scopes cannot be null'); + } $allowedValues = $this->getScopesAllowableValues(); - if (!is_null($scopes) && array_diff($scopes, $allowedValues)) { + if (array_diff($scopes, $allowedValues)) { throw new InvalidArgumentException( sprintf( "Invalid value for 'scopes', must be one of '%s'", @@ -318,12 +397,10 @@ public function setScopes(?array $scopes) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -331,7 +408,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -344,13 +421,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -362,12 +437,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -376,8 +449,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubOptions.php b/sdks/php/src/Model/SubOptions.php index 0ac89500c..b86fa5b7f 100644 --- a/sdks/php/src/Model/SubOptions.php +++ b/sdks/php/src/Model/SubOptions.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,11 +38,8 @@ * * @category Class * @description Additional options supported by API App. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubOptions implements ModelInterface, ArrayAccess, JsonSerializable { @@ -75,6 +72,22 @@ class SubOptions implements ModelInterface, ArrayAccess, JsonSerializable 'can_insert_everywhere' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'can_insert_everywhere' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -95,6 +108,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -167,37 +224,55 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['can_insert_everywhere'] = $data['can_insert_everywhere'] ?? false; + $this->setIfExists('can_insert_everywhere', $data ?? [], false); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubOptions { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubOptions { - /** @var SubOptions $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubOptions */ + return ObjectSerializer::deserialize( $data, SubOptions::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -207,9 +282,7 @@ public static function init(array $data): SubOptions */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -242,6 +315,9 @@ public function getCanInsertEverywhere() */ public function setCanInsertEverywhere(?bool $can_insert_everywhere) { + if (is_null($can_insert_everywhere)) { + throw new InvalidArgumentException('non-nullable can_insert_everywhere cannot be null'); + } $this->container['can_insert_everywhere'] = $can_insert_everywhere; return $this; @@ -250,12 +326,10 @@ public function setCanInsertEverywhere(?bool $can_insert_everywhere) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -263,7 +337,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -276,13 +350,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -294,12 +366,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -308,8 +378,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubSignatureRequestGroupedSigners.php b/sdks/php/src/Model/SubSignatureRequestGroupedSigners.php index 950503cd4..2d15bc241 100644 --- a/sdks/php/src/Model/SubSignatureRequestGroupedSigners.php +++ b/sdks/php/src/Model/SubSignatureRequestGroupedSigners.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * SubSignatureRequestGroupedSigners Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubSignatureRequestGroupedSigners implements ModelInterface, ArrayAccess, JsonSerializable { @@ -78,6 +75,24 @@ class SubSignatureRequestGroupedSigners implements ModelInterface, ArrayAccess, 'order' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'group' => false, + 'signers' => false, + 'order' => true, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -98,6 +113,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -176,39 +235,57 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['group'] = $data['group'] ?? null; - $this->container['signers'] = $data['signers'] ?? null; - $this->container['order'] = $data['order'] ?? null; + $this->setIfExists('group', $data ?? [], null); + $this->setIfExists('signers', $data ?? [], null); + $this->setIfExists('order', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubSignatureRequestGroupedSigners { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubSignatureRequestGroupedSigners { - /** @var SubSignatureRequestGroupedSigners $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubSignatureRequestGroupedSigners */ + return ObjectSerializer::deserialize( $data, SubSignatureRequestGroupedSigners::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -226,7 +303,6 @@ public function listInvalidProperties() if ($this->container['signers'] === null) { $invalidProperties[] = "'signers' can't be null"; } - return $invalidProperties; } @@ -260,6 +336,9 @@ public function getGroup() */ public function setGroup(string $group) { + if (is_null($group)) { + throw new InvalidArgumentException('non-nullable group cannot be null'); + } $this->container['group'] = $group; return $this; @@ -284,6 +363,9 @@ public function getSigners() */ public function setSigners(array $signers) { + if (is_null($signers)) { + throw new InvalidArgumentException('non-nullable signers cannot be null'); + } $this->container['signers'] = $signers; return $this; @@ -308,6 +390,16 @@ public function getOrder() */ public function setOrder(?int $order) { + if (is_null($order)) { + array_push($this->openAPINullablesSetToNull, 'order'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('order', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['order'] = $order; return $this; @@ -316,12 +408,10 @@ public function setOrder(?int $order) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -329,7 +419,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -342,13 +432,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -360,12 +448,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -374,8 +460,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubSignatureRequestSigner.php b/sdks/php/src/Model/SubSignatureRequestSigner.php index eca198308..64133e165 100644 --- a/sdks/php/src/Model/SubSignatureRequestSigner.php +++ b/sdks/php/src/Model/SubSignatureRequestSigner.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -38,11 +37,8 @@ * SubSignatureRequestSigner Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubSignatureRequestSigner implements ModelInterface, ArrayAccess, JsonSerializable { @@ -85,6 +81,27 @@ class SubSignatureRequestSigner implements ModelInterface, ArrayAccess, JsonSeri 'sms_phone_number_type' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'name' => false, + 'email_address' => false, + 'order' => true, + 'pin' => false, + 'sms_phone_number' => false, + 'sms_phone_number_type' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -105,6 +122,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -208,42 +269,60 @@ public function getSmsPhoneNumberTypeAllowableValues() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['name'] = $data['name'] ?? null; - $this->container['email_address'] = $data['email_address'] ?? null; - $this->container['order'] = $data['order'] ?? null; - $this->container['pin'] = $data['pin'] ?? null; - $this->container['sms_phone_number'] = $data['sms_phone_number'] ?? null; - $this->container['sms_phone_number_type'] = $data['sms_phone_number_type'] ?? null; + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('email_address', $data ?? [], null); + $this->setIfExists('order', $data ?? [], null); + $this->setIfExists('pin', $data ?? [], null); + $this->setIfExists('sms_phone_number', $data ?? [], null); + $this->setIfExists('sms_phone_number_type', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubSignatureRequestSigner { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubSignatureRequestSigner { - /** @var SubSignatureRequestSigner $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubSignatureRequestSigner */ + return ObjectSerializer::deserialize( $data, SubSignatureRequestSigner::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -311,6 +390,9 @@ public function getName() */ public function setName(string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -335,6 +417,9 @@ public function getEmailAddress() */ public function setEmailAddress(string $email_address) { + if (is_null($email_address)) { + throw new InvalidArgumentException('non-nullable email_address cannot be null'); + } $this->container['email_address'] = $email_address; return $this; @@ -359,6 +444,16 @@ public function getOrder() */ public function setOrder(?int $order) { + if (is_null($order)) { + array_push($this->openAPINullablesSetToNull, 'order'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('order', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['order'] = $order; return $this; @@ -383,10 +478,13 @@ public function getPin() */ public function setPin(?string $pin) { - if (!is_null($pin) && (mb_strlen($pin) > 12)) { + if (is_null($pin)) { + throw new InvalidArgumentException('non-nullable pin cannot be null'); + } + if (mb_strlen($pin) > 12) { throw new InvalidArgumentException('invalid length for $pin when calling SubSignatureRequestSigner., must be smaller than or equal to 12.'); } - if (!is_null($pin) && (mb_strlen($pin) < 4)) { + if (mb_strlen($pin) < 4) { throw new InvalidArgumentException('invalid length for $pin when calling SubSignatureRequestSigner., must be bigger than or equal to 4.'); } @@ -414,6 +512,9 @@ public function getSmsPhoneNumber() */ public function setSmsPhoneNumber(?string $sms_phone_number) { + if (is_null($sms_phone_number)) { + throw new InvalidArgumentException('non-nullable sms_phone_number cannot be null'); + } $this->container['sms_phone_number'] = $sms_phone_number; return $this; @@ -438,8 +539,11 @@ public function getSmsPhoneNumberType() */ public function setSmsPhoneNumberType(?string $sms_phone_number_type) { + if (is_null($sms_phone_number_type)) { + throw new InvalidArgumentException('non-nullable sms_phone_number_type cannot be null'); + } $allowedValues = $this->getSmsPhoneNumberTypeAllowableValues(); - if (!is_null($sms_phone_number_type) && !in_array($sms_phone_number_type, $allowedValues, true)) { + if (!in_array($sms_phone_number_type, $allowedValues, true)) { throw new InvalidArgumentException( sprintf( "Invalid value '%s' for 'sms_phone_number_type', must be one of '%s'", @@ -456,12 +560,10 @@ public function setSmsPhoneNumberType(?string $sms_phone_number_type) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -469,7 +571,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -482,13 +584,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -500,12 +600,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -514,8 +612,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubSignatureRequestTemplateSigner.php b/sdks/php/src/Model/SubSignatureRequestTemplateSigner.php index d0c2f7c9a..15070e31f 100644 --- a/sdks/php/src/Model/SubSignatureRequestTemplateSigner.php +++ b/sdks/php/src/Model/SubSignatureRequestTemplateSigner.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -38,11 +37,8 @@ * SubSignatureRequestTemplateSigner Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubSignatureRequestTemplateSigner implements ModelInterface, ArrayAccess, JsonSerializable { @@ -85,6 +81,27 @@ class SubSignatureRequestTemplateSigner implements ModelInterface, ArrayAccess, 'sms_phone_number_type' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'role' => false, + 'name' => false, + 'email_address' => false, + 'pin' => false, + 'sms_phone_number' => false, + 'sms_phone_number_type' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -105,6 +122,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -208,42 +269,60 @@ public function getSmsPhoneNumberTypeAllowableValues() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['role'] = $data['role'] ?? null; - $this->container['name'] = $data['name'] ?? null; - $this->container['email_address'] = $data['email_address'] ?? null; - $this->container['pin'] = $data['pin'] ?? null; - $this->container['sms_phone_number'] = $data['sms_phone_number'] ?? null; - $this->container['sms_phone_number_type'] = $data['sms_phone_number_type'] ?? null; + $this->setIfExists('role', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('email_address', $data ?? [], null); + $this->setIfExists('pin', $data ?? [], null); + $this->setIfExists('sms_phone_number', $data ?? [], null); + $this->setIfExists('sms_phone_number_type', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubSignatureRequestTemplateSigner { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubSignatureRequestTemplateSigner { - /** @var SubSignatureRequestTemplateSigner $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubSignatureRequestTemplateSigner */ + return ObjectSerializer::deserialize( $data, SubSignatureRequestTemplateSigner::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -314,6 +393,9 @@ public function getRole() */ public function setRole(string $role) { + if (is_null($role)) { + throw new InvalidArgumentException('non-nullable role cannot be null'); + } $this->container['role'] = $role; return $this; @@ -338,6 +420,9 @@ public function getName() */ public function setName(string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -362,6 +447,9 @@ public function getEmailAddress() */ public function setEmailAddress(string $email_address) { + if (is_null($email_address)) { + throw new InvalidArgumentException('non-nullable email_address cannot be null'); + } $this->container['email_address'] = $email_address; return $this; @@ -386,10 +474,13 @@ public function getPin() */ public function setPin(?string $pin) { - if (!is_null($pin) && (mb_strlen($pin) > 12)) { + if (is_null($pin)) { + throw new InvalidArgumentException('non-nullable pin cannot be null'); + } + if (mb_strlen($pin) > 12) { throw new InvalidArgumentException('invalid length for $pin when calling SubSignatureRequestTemplateSigner., must be smaller than or equal to 12.'); } - if (!is_null($pin) && (mb_strlen($pin) < 4)) { + if (mb_strlen($pin) < 4) { throw new InvalidArgumentException('invalid length for $pin when calling SubSignatureRequestTemplateSigner., must be bigger than or equal to 4.'); } @@ -417,6 +508,9 @@ public function getSmsPhoneNumber() */ public function setSmsPhoneNumber(?string $sms_phone_number) { + if (is_null($sms_phone_number)) { + throw new InvalidArgumentException('non-nullable sms_phone_number cannot be null'); + } $this->container['sms_phone_number'] = $sms_phone_number; return $this; @@ -441,8 +535,11 @@ public function getSmsPhoneNumberType() */ public function setSmsPhoneNumberType(?string $sms_phone_number_type) { + if (is_null($sms_phone_number_type)) { + throw new InvalidArgumentException('non-nullable sms_phone_number_type cannot be null'); + } $allowedValues = $this->getSmsPhoneNumberTypeAllowableValues(); - if (!is_null($sms_phone_number_type) && !in_array($sms_phone_number_type, $allowedValues, true)) { + if (!in_array($sms_phone_number_type, $allowedValues, true)) { throw new InvalidArgumentException( sprintf( "Invalid value '%s' for 'sms_phone_number_type', must be one of '%s'", @@ -459,12 +556,10 @@ public function setSmsPhoneNumberType(?string $sms_phone_number_type) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -472,7 +567,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -485,13 +580,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -503,12 +596,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -517,8 +608,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubSigningOptions.php b/sdks/php/src/Model/SubSigningOptions.php index d6151831f..8cbaff0f0 100644 --- a/sdks/php/src/Model/SubSigningOptions.php +++ b/sdks/php/src/Model/SubSigningOptions.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -39,11 +38,8 @@ * * @category Class * @description This allows the requester to specify the types allowed for creating a signature. **NOTE:** If `signing_options` are not defined in the request, the allowed types will default to those specified in the account settings. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubSigningOptions implements ModelInterface, ArrayAccess, JsonSerializable { @@ -84,6 +80,26 @@ class SubSigningOptions implements ModelInterface, ArrayAccess, JsonSerializable 'upload' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'default_type' => false, + 'draw' => false, + 'phone' => false, + 'type' => false, + 'upload' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -104,6 +120,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -208,41 +268,59 @@ public function getDefaultTypeAllowableValues() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['default_type'] = $data['default_type'] ?? null; - $this->container['draw'] = $data['draw'] ?? false; - $this->container['phone'] = $data['phone'] ?? false; - $this->container['type'] = $data['type'] ?? false; - $this->container['upload'] = $data['upload'] ?? false; + $this->setIfExists('default_type', $data ?? [], null); + $this->setIfExists('draw', $data ?? [], false); + $this->setIfExists('phone', $data ?? [], false); + $this->setIfExists('type', $data ?? [], false); + $this->setIfExists('upload', $data ?? [], false); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubSigningOptions { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubSigningOptions { - /** @var SubSigningOptions $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubSigningOptions */ + return ObjectSerializer::deserialize( $data, SubSigningOptions::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -299,6 +377,9 @@ public function getDefaultType() */ public function setDefaultType(string $default_type) { + if (is_null($default_type)) { + throw new InvalidArgumentException('non-nullable default_type cannot be null'); + } $allowedValues = $this->getDefaultTypeAllowableValues(); if (!in_array($default_type, $allowedValues, true)) { throw new InvalidArgumentException( @@ -333,6 +414,9 @@ public function getDraw() */ public function setDraw(?bool $draw) { + if (is_null($draw)) { + throw new InvalidArgumentException('non-nullable draw cannot be null'); + } $this->container['draw'] = $draw; return $this; @@ -357,6 +441,9 @@ public function getPhone() */ public function setPhone(?bool $phone) { + if (is_null($phone)) { + throw new InvalidArgumentException('non-nullable phone cannot be null'); + } $this->container['phone'] = $phone; return $this; @@ -381,6 +468,9 @@ public function getType() */ public function setType(?bool $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -405,6 +495,9 @@ public function getUpload() */ public function setUpload(?bool $upload) { + if (is_null($upload)) { + throw new InvalidArgumentException('non-nullable upload cannot be null'); + } $this->container['upload'] = $upload; return $this; @@ -413,12 +506,10 @@ public function setUpload(?bool $upload) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -426,7 +517,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -439,13 +530,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -457,12 +546,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -471,8 +558,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubTeamResponse.php b/sdks/php/src/Model/SubTeamResponse.php index da57cfff9..60ecc442a 100644 --- a/sdks/php/src/Model/SubTeamResponse.php +++ b/sdks/php/src/Model/SubTeamResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * SubTeamResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class SubTeamResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -77,6 +73,23 @@ class SubTeamResponse implements ModelInterface, ArrayAccess, JsonSerializable 'name' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'team_id' => false, + 'name' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -97,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -172,38 +229,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['team_id'] = $data['team_id'] ?? null; - $this->container['name'] = $data['name'] ?? null; + $this->setIfExists('team_id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubTeamResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubTeamResponse { - /** @var SubTeamResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubTeamResponse */ + return ObjectSerializer::deserialize( $data, SubTeamResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -213,9 +288,7 @@ public static function init(array $data): SubTeamResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -248,6 +321,9 @@ public function getTeamId() */ public function setTeamId(?string $team_id) { + if (is_null($team_id)) { + throw new InvalidArgumentException('non-nullable team_id cannot be null'); + } $this->container['team_id'] = $team_id; return $this; @@ -272,6 +348,9 @@ public function getName() */ public function setName(?string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -280,12 +359,10 @@ public function setName(?string $name) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -293,7 +370,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -306,13 +383,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -324,12 +399,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -338,8 +411,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubTemplateRole.php b/sdks/php/src/Model/SubTemplateRole.php index 399c64b2b..2678da93a 100644 --- a/sdks/php/src/Model/SubTemplateRole.php +++ b/sdks/php/src/Model/SubTemplateRole.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * SubTemplateRole Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubTemplateRole implements ModelInterface, ArrayAccess, JsonSerializable { @@ -76,6 +73,23 @@ class SubTemplateRole implements ModelInterface, ArrayAccess, JsonSerializable 'order' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'name' => false, + 'order' => true, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -96,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -171,38 +229,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['name'] = $data['name'] ?? null; - $this->container['order'] = $data['order'] ?? null; + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('order', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubTemplateRole { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubTemplateRole { - /** @var SubTemplateRole $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubTemplateRole */ + return ObjectSerializer::deserialize( $data, SubTemplateRole::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -212,9 +288,7 @@ public static function init(array $data): SubTemplateRole */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -247,6 +321,9 @@ public function getName() */ public function setName(?string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -271,6 +348,16 @@ public function getOrder() */ public function setOrder(?int $order) { + if (is_null($order)) { + array_push($this->openAPINullablesSetToNull, 'order'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('order', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['order'] = $order; return $this; @@ -279,12 +366,10 @@ public function setOrder(?int $order) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -292,7 +377,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -305,13 +390,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -323,12 +406,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -337,8 +418,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubUnclaimedDraftSigner.php b/sdks/php/src/Model/SubUnclaimedDraftSigner.php index 646a6454f..acc466356 100644 --- a/sdks/php/src/Model/SubUnclaimedDraftSigner.php +++ b/sdks/php/src/Model/SubUnclaimedDraftSigner.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * SubUnclaimedDraftSigner Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubUnclaimedDraftSigner implements ModelInterface, ArrayAccess, JsonSerializable { @@ -78,6 +75,24 @@ class SubUnclaimedDraftSigner implements ModelInterface, ArrayAccess, JsonSerial 'order' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'email_address' => false, + 'name' => false, + 'order' => true, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -98,6 +113,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -176,39 +235,57 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['email_address'] = $data['email_address'] ?? null; - $this->container['name'] = $data['name'] ?? null; - $this->container['order'] = $data['order'] ?? null; + $this->setIfExists('email_address', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('order', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubUnclaimedDraftSigner { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubUnclaimedDraftSigner { - /** @var SubUnclaimedDraftSigner $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubUnclaimedDraftSigner */ + return ObjectSerializer::deserialize( $data, SubUnclaimedDraftSigner::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -226,7 +303,6 @@ public function listInvalidProperties() if ($this->container['name'] === null) { $invalidProperties[] = "'name' can't be null"; } - return $invalidProperties; } @@ -260,6 +336,9 @@ public function getEmailAddress() */ public function setEmailAddress(string $email_address) { + if (is_null($email_address)) { + throw new InvalidArgumentException('non-nullable email_address cannot be null'); + } $this->container['email_address'] = $email_address; return $this; @@ -284,6 +363,9 @@ public function getName() */ public function setName(string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -308,6 +390,16 @@ public function getOrder() */ public function setOrder(?int $order) { + if (is_null($order)) { + array_push($this->openAPINullablesSetToNull, 'order'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('order', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['order'] = $order; return $this; @@ -316,12 +408,10 @@ public function setOrder(?int $order) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -329,7 +419,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -342,13 +432,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -360,12 +448,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -374,8 +460,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubUnclaimedDraftTemplateSigner.php b/sdks/php/src/Model/SubUnclaimedDraftTemplateSigner.php index f55a46edf..9daffb1e4 100644 --- a/sdks/php/src/Model/SubUnclaimedDraftTemplateSigner.php +++ b/sdks/php/src/Model/SubUnclaimedDraftTemplateSigner.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * SubUnclaimedDraftTemplateSigner Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubUnclaimedDraftTemplateSigner implements ModelInterface, ArrayAccess, JsonSerializable { @@ -78,6 +75,24 @@ class SubUnclaimedDraftTemplateSigner implements ModelInterface, ArrayAccess, Js 'email_address' => 'email', ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'role' => false, + 'name' => false, + 'email_address' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -98,6 +113,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -176,39 +235,57 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['role'] = $data['role'] ?? null; - $this->container['name'] = $data['name'] ?? null; - $this->container['email_address'] = $data['email_address'] ?? null; + $this->setIfExists('role', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('email_address', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubUnclaimedDraftTemplateSigner { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubUnclaimedDraftTemplateSigner { - /** @var SubUnclaimedDraftTemplateSigner $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubUnclaimedDraftTemplateSigner */ + return ObjectSerializer::deserialize( $data, SubUnclaimedDraftTemplateSigner::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -229,7 +306,6 @@ public function listInvalidProperties() if ($this->container['email_address'] === null) { $invalidProperties[] = "'email_address' can't be null"; } - return $invalidProperties; } @@ -263,6 +339,9 @@ public function getRole() */ public function setRole(string $role) { + if (is_null($role)) { + throw new InvalidArgumentException('non-nullable role cannot be null'); + } $this->container['role'] = $role; return $this; @@ -287,6 +366,9 @@ public function getName() */ public function setName(string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -311,6 +393,9 @@ public function getEmailAddress() */ public function setEmailAddress(string $email_address) { + if (is_null($email_address)) { + throw new InvalidArgumentException('non-nullable email_address cannot be null'); + } $this->container['email_address'] = $email_address; return $this; @@ -319,12 +404,10 @@ public function setEmailAddress(string $email_address) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -332,7 +415,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -345,13 +428,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -363,12 +444,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -377,8 +456,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/SubWhiteLabelingOptions.php b/sdks/php/src/Model/SubWhiteLabelingOptions.php index abed8147c..4f16b4928 100644 --- a/sdks/php/src/Model/SubWhiteLabelingOptions.php +++ b/sdks/php/src/Model/SubWhiteLabelingOptions.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -39,11 +38,8 @@ * * @category Class * @description An array of elements and values serialized to a string, to be used to customize the app's signer page. (Only applies to some API plans) Take a look at our [white labeling guide](https://developers.hellosign.com/api/reference/premium-branding/) to learn more. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class SubWhiteLabelingOptions implements ModelInterface, ArrayAccess, JsonSerializable { @@ -104,6 +100,36 @@ class SubWhiteLabelingOptions implements ModelInterface, ArrayAccess, JsonSerial 'reset_to_default' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'header_background_color' => false, + 'legal_version' => false, + 'link_color' => false, + 'page_background_color' => false, + 'primary_button_color' => false, + 'primary_button_color_hover' => false, + 'primary_button_text_color' => false, + 'primary_button_text_color_hover' => false, + 'secondary_button_color' => false, + 'secondary_button_color_hover' => false, + 'secondary_button_text_color' => false, + 'secondary_button_text_color_hover' => false, + 'text_color1' => false, + 'text_color2' => false, + 'reset_to_default' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -124,6 +150,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -254,51 +324,69 @@ public function getLegalVersionAllowableValues() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['header_background_color'] = $data['header_background_color'] ?? '#1A1A1A'; - $this->container['legal_version'] = $data['legal_version'] ?? 'terms1'; - $this->container['link_color'] = $data['link_color'] ?? '#00B3E6'; - $this->container['page_background_color'] = $data['page_background_color'] ?? '#F7F8F9'; - $this->container['primary_button_color'] = $data['primary_button_color'] ?? '#00B3E6'; - $this->container['primary_button_color_hover'] = $data['primary_button_color_hover'] ?? '#00B3E6'; - $this->container['primary_button_text_color'] = $data['primary_button_text_color'] ?? '#FFFFFF'; - $this->container['primary_button_text_color_hover'] = $data['primary_button_text_color_hover'] ?? '#FFFFFF'; - $this->container['secondary_button_color'] = $data['secondary_button_color'] ?? '#FFFFFF'; - $this->container['secondary_button_color_hover'] = $data['secondary_button_color_hover'] ?? '#FFFFFF'; - $this->container['secondary_button_text_color'] = $data['secondary_button_text_color'] ?? '#00B3E6'; - $this->container['secondary_button_text_color_hover'] = $data['secondary_button_text_color_hover'] ?? '#00B3E6'; - $this->container['text_color1'] = $data['text_color1'] ?? '#808080'; - $this->container['text_color2'] = $data['text_color2'] ?? '#FFFFFF'; - $this->container['reset_to_default'] = $data['reset_to_default'] ?? null; - } - - /** @deprecated use ::init() */ + $this->setIfExists('header_background_color', $data ?? [], '#1A1A1A'); + $this->setIfExists('legal_version', $data ?? [], 'terms1'); + $this->setIfExists('link_color', $data ?? [], '#00B3E6'); + $this->setIfExists('page_background_color', $data ?? [], '#F7F8F9'); + $this->setIfExists('primary_button_color', $data ?? [], '#00B3E6'); + $this->setIfExists('primary_button_color_hover', $data ?? [], '#00B3E6'); + $this->setIfExists('primary_button_text_color', $data ?? [], '#FFFFFF'); + $this->setIfExists('primary_button_text_color_hover', $data ?? [], '#FFFFFF'); + $this->setIfExists('secondary_button_color', $data ?? [], '#FFFFFF'); + $this->setIfExists('secondary_button_color_hover', $data ?? [], '#FFFFFF'); + $this->setIfExists('secondary_button_text_color', $data ?? [], '#00B3E6'); + $this->setIfExists('secondary_button_text_color_hover', $data ?? [], '#00B3E6'); + $this->setIfExists('text_color1', $data ?? [], '#808080'); + $this->setIfExists('text_color2', $data ?? [], '#FFFFFF'); + $this->setIfExists('reset_to_default', $data ?? [], null); + } + + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): SubWhiteLabelingOptions { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): SubWhiteLabelingOptions { - /** @var SubWhiteLabelingOptions $obj */ - $obj = ObjectSerializer::deserialize( + /** @var SubWhiteLabelingOptions */ + return ObjectSerializer::deserialize( $data, SubWhiteLabelingOptions::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -352,6 +440,9 @@ public function getHeaderBackgroundColor() */ public function setHeaderBackgroundColor(?string $header_background_color) { + if (is_null($header_background_color)) { + throw new InvalidArgumentException('non-nullable header_background_color cannot be null'); + } $this->container['header_background_color'] = $header_background_color; return $this; @@ -376,8 +467,11 @@ public function getLegalVersion() */ public function setLegalVersion(?string $legal_version) { + if (is_null($legal_version)) { + throw new InvalidArgumentException('non-nullable legal_version cannot be null'); + } $allowedValues = $this->getLegalVersionAllowableValues(); - if (!is_null($legal_version) && !in_array($legal_version, $allowedValues, true)) { + if (!in_array($legal_version, $allowedValues, true)) { throw new InvalidArgumentException( sprintf( "Invalid value '%s' for 'legal_version', must be one of '%s'", @@ -410,6 +504,9 @@ public function getLinkColor() */ public function setLinkColor(?string $link_color) { + if (is_null($link_color)) { + throw new InvalidArgumentException('non-nullable link_color cannot be null'); + } $this->container['link_color'] = $link_color; return $this; @@ -434,6 +531,9 @@ public function getPageBackgroundColor() */ public function setPageBackgroundColor(?string $page_background_color) { + if (is_null($page_background_color)) { + throw new InvalidArgumentException('non-nullable page_background_color cannot be null'); + } $this->container['page_background_color'] = $page_background_color; return $this; @@ -458,6 +558,9 @@ public function getPrimaryButtonColor() */ public function setPrimaryButtonColor(?string $primary_button_color) { + if (is_null($primary_button_color)) { + throw new InvalidArgumentException('non-nullable primary_button_color cannot be null'); + } $this->container['primary_button_color'] = $primary_button_color; return $this; @@ -482,6 +585,9 @@ public function getPrimaryButtonColorHover() */ public function setPrimaryButtonColorHover(?string $primary_button_color_hover) { + if (is_null($primary_button_color_hover)) { + throw new InvalidArgumentException('non-nullable primary_button_color_hover cannot be null'); + } $this->container['primary_button_color_hover'] = $primary_button_color_hover; return $this; @@ -506,6 +612,9 @@ public function getPrimaryButtonTextColor() */ public function setPrimaryButtonTextColor(?string $primary_button_text_color) { + if (is_null($primary_button_text_color)) { + throw new InvalidArgumentException('non-nullable primary_button_text_color cannot be null'); + } $this->container['primary_button_text_color'] = $primary_button_text_color; return $this; @@ -530,6 +639,9 @@ public function getPrimaryButtonTextColorHover() */ public function setPrimaryButtonTextColorHover(?string $primary_button_text_color_hover) { + if (is_null($primary_button_text_color_hover)) { + throw new InvalidArgumentException('non-nullable primary_button_text_color_hover cannot be null'); + } $this->container['primary_button_text_color_hover'] = $primary_button_text_color_hover; return $this; @@ -554,6 +666,9 @@ public function getSecondaryButtonColor() */ public function setSecondaryButtonColor(?string $secondary_button_color) { + if (is_null($secondary_button_color)) { + throw new InvalidArgumentException('non-nullable secondary_button_color cannot be null'); + } $this->container['secondary_button_color'] = $secondary_button_color; return $this; @@ -578,6 +693,9 @@ public function getSecondaryButtonColorHover() */ public function setSecondaryButtonColorHover(?string $secondary_button_color_hover) { + if (is_null($secondary_button_color_hover)) { + throw new InvalidArgumentException('non-nullable secondary_button_color_hover cannot be null'); + } $this->container['secondary_button_color_hover'] = $secondary_button_color_hover; return $this; @@ -602,6 +720,9 @@ public function getSecondaryButtonTextColor() */ public function setSecondaryButtonTextColor(?string $secondary_button_text_color) { + if (is_null($secondary_button_text_color)) { + throw new InvalidArgumentException('non-nullable secondary_button_text_color cannot be null'); + } $this->container['secondary_button_text_color'] = $secondary_button_text_color; return $this; @@ -626,6 +747,9 @@ public function getSecondaryButtonTextColorHover() */ public function setSecondaryButtonTextColorHover(?string $secondary_button_text_color_hover) { + if (is_null($secondary_button_text_color_hover)) { + throw new InvalidArgumentException('non-nullable secondary_button_text_color_hover cannot be null'); + } $this->container['secondary_button_text_color_hover'] = $secondary_button_text_color_hover; return $this; @@ -650,6 +774,9 @@ public function getTextColor1() */ public function setTextColor1(?string $text_color1) { + if (is_null($text_color1)) { + throw new InvalidArgumentException('non-nullable text_color1 cannot be null'); + } $this->container['text_color1'] = $text_color1; return $this; @@ -674,6 +801,9 @@ public function getTextColor2() */ public function setTextColor2(?string $text_color2) { + if (is_null($text_color2)) { + throw new InvalidArgumentException('non-nullable text_color2 cannot be null'); + } $this->container['text_color2'] = $text_color2; return $this; @@ -698,6 +828,9 @@ public function getResetToDefault() */ public function setResetToDefault(?bool $reset_to_default) { + if (is_null($reset_to_default)) { + throw new InvalidArgumentException('non-nullable reset_to_default cannot be null'); + } $this->container['reset_to_default'] = $reset_to_default; return $this; @@ -706,12 +839,10 @@ public function setResetToDefault(?bool $reset_to_default) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -719,7 +850,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -732,13 +863,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -750,12 +879,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -764,8 +891,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TeamAddMemberRequest.php b/sdks/php/src/Model/TeamAddMemberRequest.php index 1caf129bf..e38abb02f 100644 --- a/sdks/php/src/Model/TeamAddMemberRequest.php +++ b/sdks/php/src/Model/TeamAddMemberRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -38,11 +37,8 @@ * TeamAddMemberRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TeamAddMemberRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -79,6 +75,24 @@ class TeamAddMemberRequest implements ModelInterface, ArrayAccess, JsonSerializa 'role' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'account_id' => false, + 'email_address' => false, + 'role' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -99,6 +113,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -197,39 +255,57 @@ public function getRoleAllowableValues() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['account_id'] = $data['account_id'] ?? null; - $this->container['email_address'] = $data['email_address'] ?? null; - $this->container['role'] = $data['role'] ?? null; + $this->setIfExists('account_id', $data ?? [], null); + $this->setIfExists('email_address', $data ?? [], null); + $this->setIfExists('role', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TeamAddMemberRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TeamAddMemberRequest { - /** @var TeamAddMemberRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TeamAddMemberRequest */ + return ObjectSerializer::deserialize( $data, TeamAddMemberRequest::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -283,6 +359,9 @@ public function getAccountId() */ public function setAccountId(?string $account_id) { + if (is_null($account_id)) { + throw new InvalidArgumentException('non-nullable account_id cannot be null'); + } $this->container['account_id'] = $account_id; return $this; @@ -307,6 +386,9 @@ public function getEmailAddress() */ public function setEmailAddress(?string $email_address) { + if (is_null($email_address)) { + throw new InvalidArgumentException('non-nullable email_address cannot be null'); + } $this->container['email_address'] = $email_address; return $this; @@ -331,8 +413,11 @@ public function getRole() */ public function setRole(?string $role) { + if (is_null($role)) { + throw new InvalidArgumentException('non-nullable role cannot be null'); + } $allowedValues = $this->getRoleAllowableValues(); - if (!is_null($role) && !in_array($role, $allowedValues, true)) { + if (!in_array($role, $allowedValues, true)) { throw new InvalidArgumentException( sprintf( "Invalid value '%s' for 'role', must be one of '%s'", @@ -349,12 +434,10 @@ public function setRole(?string $role) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -362,7 +445,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -375,13 +458,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -393,12 +474,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -407,8 +486,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TeamCreateRequest.php b/sdks/php/src/Model/TeamCreateRequest.php index ad51504c4..6ba37cc71 100644 --- a/sdks/php/src/Model/TeamCreateRequest.php +++ b/sdks/php/src/Model/TeamCreateRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * TeamCreateRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TeamCreateRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -74,6 +71,22 @@ class TeamCreateRequest implements ModelInterface, ArrayAccess, JsonSerializable 'name' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'name' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -94,6 +107,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -166,37 +223,55 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['name'] = $data['name'] ?? 'Untitled Team'; + $this->setIfExists('name', $data ?? [], 'Untitled Team'); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TeamCreateRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TeamCreateRequest { - /** @var TeamCreateRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TeamCreateRequest */ + return ObjectSerializer::deserialize( $data, TeamCreateRequest::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -206,9 +281,7 @@ public static function init(array $data): TeamCreateRequest */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -241,6 +314,9 @@ public function getName() */ public function setName(?string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -249,12 +325,10 @@ public function setName(?string $name) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -262,7 +336,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -275,13 +349,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -293,12 +365,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -307,8 +377,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TeamGetInfoResponse.php b/sdks/php/src/Model/TeamGetInfoResponse.php index d46fb6e9c..6680e9e9c 100644 --- a/sdks/php/src/Model/TeamGetInfoResponse.php +++ b/sdks/php/src/Model/TeamGetInfoResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * TeamGetInfoResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class TeamGetInfoResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -77,6 +73,23 @@ class TeamGetInfoResponse implements ModelInterface, ArrayAccess, JsonSerializab 'warnings' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'team' => false, + 'warnings' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -97,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -172,38 +229,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['team'] = $data['team'] ?? null; - $this->container['warnings'] = $data['warnings'] ?? null; + $this->setIfExists('team', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TeamGetInfoResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TeamGetInfoResponse { - /** @var TeamGetInfoResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TeamGetInfoResponse */ + return ObjectSerializer::deserialize( $data, TeamGetInfoResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -213,9 +288,7 @@ public static function init(array $data): TeamGetInfoResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -248,6 +321,9 @@ public function getTeam() */ public function setTeam(?TeamInfoResponse $team) { + if (is_null($team)) { + throw new InvalidArgumentException('non-nullable team cannot be null'); + } $this->container['team'] = $team; return $this; @@ -272,6 +348,9 @@ public function getWarnings() */ public function setWarnings(?array $warnings) { + if (is_null($warnings)) { + throw new InvalidArgumentException('non-nullable warnings cannot be null'); + } $this->container['warnings'] = $warnings; return $this; @@ -280,12 +359,10 @@ public function setWarnings(?array $warnings) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -293,7 +370,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -306,13 +383,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -324,12 +399,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -338,8 +411,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TeamGetResponse.php b/sdks/php/src/Model/TeamGetResponse.php index 0ff83b21a..c26030e3e 100644 --- a/sdks/php/src/Model/TeamGetResponse.php +++ b/sdks/php/src/Model/TeamGetResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * TeamGetResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class TeamGetResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -77,6 +73,23 @@ class TeamGetResponse implements ModelInterface, ArrayAccess, JsonSerializable 'warnings' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'team' => false, + 'warnings' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -97,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -172,38 +229,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['team'] = $data['team'] ?? null; - $this->container['warnings'] = $data['warnings'] ?? null; + $this->setIfExists('team', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TeamGetResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TeamGetResponse { - /** @var TeamGetResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TeamGetResponse */ + return ObjectSerializer::deserialize( $data, TeamGetResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -213,9 +288,7 @@ public static function init(array $data): TeamGetResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -248,6 +321,9 @@ public function getTeam() */ public function setTeam(?TeamResponse $team) { + if (is_null($team)) { + throw new InvalidArgumentException('non-nullable team cannot be null'); + } $this->container['team'] = $team; return $this; @@ -272,6 +348,9 @@ public function getWarnings() */ public function setWarnings(?array $warnings) { + if (is_null($warnings)) { + throw new InvalidArgumentException('non-nullable warnings cannot be null'); + } $this->container['warnings'] = $warnings; return $this; @@ -280,12 +359,10 @@ public function setWarnings(?array $warnings) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -293,7 +370,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -306,13 +383,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -324,12 +399,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -338,8 +411,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TeamInfoResponse.php b/sdks/php/src/Model/TeamInfoResponse.php index 782008377..3d5ad124a 100644 --- a/sdks/php/src/Model/TeamInfoResponse.php +++ b/sdks/php/src/Model/TeamInfoResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * TeamInfoResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class TeamInfoResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -83,6 +79,26 @@ class TeamInfoResponse implements ModelInterface, ArrayAccess, JsonSerializable 'num_sub_teams' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'team_id' => false, + 'team_parent' => true, + 'name' => false, + 'num_members' => false, + 'num_sub_teams' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -103,6 +119,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -187,41 +247,59 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['team_id'] = $data['team_id'] ?? null; - $this->container['team_parent'] = $data['team_parent'] ?? null; - $this->container['name'] = $data['name'] ?? null; - $this->container['num_members'] = $data['num_members'] ?? null; - $this->container['num_sub_teams'] = $data['num_sub_teams'] ?? null; + $this->setIfExists('team_id', $data ?? [], null); + $this->setIfExists('team_parent', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('num_members', $data ?? [], null); + $this->setIfExists('num_sub_teams', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TeamInfoResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TeamInfoResponse { - /** @var TeamInfoResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TeamInfoResponse */ + return ObjectSerializer::deserialize( $data, TeamInfoResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -231,9 +309,7 @@ public static function init(array $data): TeamInfoResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -266,6 +342,9 @@ public function getTeamId() */ public function setTeamId(?string $team_id) { + if (is_null($team_id)) { + throw new InvalidArgumentException('non-nullable team_id cannot be null'); + } $this->container['team_id'] = $team_id; return $this; @@ -290,6 +369,16 @@ public function getTeamParent() */ public function setTeamParent(?TeamParentResponse $team_parent) { + if (is_null($team_parent)) { + array_push($this->openAPINullablesSetToNull, 'team_parent'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('team_parent', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['team_parent'] = $team_parent; return $this; @@ -314,6 +403,9 @@ public function getName() */ public function setName(?string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -338,6 +430,9 @@ public function getNumMembers() */ public function setNumMembers(?int $num_members) { + if (is_null($num_members)) { + throw new InvalidArgumentException('non-nullable num_members cannot be null'); + } $this->container['num_members'] = $num_members; return $this; @@ -362,6 +457,9 @@ public function getNumSubTeams() */ public function setNumSubTeams(?int $num_sub_teams) { + if (is_null($num_sub_teams)) { + throw new InvalidArgumentException('non-nullable num_sub_teams cannot be null'); + } $this->container['num_sub_teams'] = $num_sub_teams; return $this; @@ -370,12 +468,10 @@ public function setNumSubTeams(?int $num_sub_teams) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -383,7 +479,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -396,13 +492,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -414,12 +508,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -428,8 +520,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TeamInviteResponse.php b/sdks/php/src/Model/TeamInviteResponse.php index 40a9b7a11..d37dae050 100644 --- a/sdks/php/src/Model/TeamInviteResponse.php +++ b/sdks/php/src/Model/TeamInviteResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * TeamInviteResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class TeamInviteResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -85,6 +81,27 @@ class TeamInviteResponse implements ModelInterface, ArrayAccess, JsonSerializabl 'expires_at' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'email_address' => false, + 'team_id' => false, + 'role' => false, + 'sent_at' => false, + 'redeemed_at' => false, + 'expires_at' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -105,6 +122,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -192,42 +253,60 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['email_address'] = $data['email_address'] ?? null; - $this->container['team_id'] = $data['team_id'] ?? null; - $this->container['role'] = $data['role'] ?? null; - $this->container['sent_at'] = $data['sent_at'] ?? null; - $this->container['redeemed_at'] = $data['redeemed_at'] ?? null; - $this->container['expires_at'] = $data['expires_at'] ?? null; + $this->setIfExists('email_address', $data ?? [], null); + $this->setIfExists('team_id', $data ?? [], null); + $this->setIfExists('role', $data ?? [], null); + $this->setIfExists('sent_at', $data ?? [], null); + $this->setIfExists('redeemed_at', $data ?? [], null); + $this->setIfExists('expires_at', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TeamInviteResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TeamInviteResponse { - /** @var TeamInviteResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TeamInviteResponse */ + return ObjectSerializer::deserialize( $data, TeamInviteResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -237,9 +316,7 @@ public static function init(array $data): TeamInviteResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -272,6 +349,9 @@ public function getEmailAddress() */ public function setEmailAddress(?string $email_address) { + if (is_null($email_address)) { + throw new InvalidArgumentException('non-nullable email_address cannot be null'); + } $this->container['email_address'] = $email_address; return $this; @@ -296,6 +376,9 @@ public function getTeamId() */ public function setTeamId(?string $team_id) { + if (is_null($team_id)) { + throw new InvalidArgumentException('non-nullable team_id cannot be null'); + } $this->container['team_id'] = $team_id; return $this; @@ -320,6 +403,9 @@ public function getRole() */ public function setRole(?string $role) { + if (is_null($role)) { + throw new InvalidArgumentException('non-nullable role cannot be null'); + } $this->container['role'] = $role; return $this; @@ -344,6 +430,9 @@ public function getSentAt() */ public function setSentAt(?int $sent_at) { + if (is_null($sent_at)) { + throw new InvalidArgumentException('non-nullable sent_at cannot be null'); + } $this->container['sent_at'] = $sent_at; return $this; @@ -368,6 +457,9 @@ public function getRedeemedAt() */ public function setRedeemedAt(?int $redeemed_at) { + if (is_null($redeemed_at)) { + throw new InvalidArgumentException('non-nullable redeemed_at cannot be null'); + } $this->container['redeemed_at'] = $redeemed_at; return $this; @@ -392,6 +484,9 @@ public function getExpiresAt() */ public function setExpiresAt(?int $expires_at) { + if (is_null($expires_at)) { + throw new InvalidArgumentException('non-nullable expires_at cannot be null'); + } $this->container['expires_at'] = $expires_at; return $this; @@ -400,12 +495,10 @@ public function setExpiresAt(?int $expires_at) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -413,7 +506,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -426,13 +519,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -444,12 +535,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -458,8 +547,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TeamInvitesResponse.php b/sdks/php/src/Model/TeamInvitesResponse.php index 5dc9d0247..c11a3f327 100644 --- a/sdks/php/src/Model/TeamInvitesResponse.php +++ b/sdks/php/src/Model/TeamInvitesResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * TeamInvitesResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class TeamInvitesResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -77,6 +73,23 @@ class TeamInvitesResponse implements ModelInterface, ArrayAccess, JsonSerializab 'warnings' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'team_invites' => false, + 'warnings' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -97,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -172,38 +229,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['team_invites'] = $data['team_invites'] ?? null; - $this->container['warnings'] = $data['warnings'] ?? null; + $this->setIfExists('team_invites', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TeamInvitesResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TeamInvitesResponse { - /** @var TeamInvitesResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TeamInvitesResponse */ + return ObjectSerializer::deserialize( $data, TeamInvitesResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -213,9 +288,7 @@ public static function init(array $data): TeamInvitesResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -248,6 +321,9 @@ public function getTeamInvites() */ public function setTeamInvites(?array $team_invites) { + if (is_null($team_invites)) { + throw new InvalidArgumentException('non-nullable team_invites cannot be null'); + } $this->container['team_invites'] = $team_invites; return $this; @@ -272,6 +348,9 @@ public function getWarnings() */ public function setWarnings(?array $warnings) { + if (is_null($warnings)) { + throw new InvalidArgumentException('non-nullable warnings cannot be null'); + } $this->container['warnings'] = $warnings; return $this; @@ -280,12 +359,10 @@ public function setWarnings(?array $warnings) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -293,7 +370,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -306,13 +383,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -324,12 +399,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -338,8 +411,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TeamMemberResponse.php b/sdks/php/src/Model/TeamMemberResponse.php index db3be66f3..ee61fbdd3 100644 --- a/sdks/php/src/Model/TeamMemberResponse.php +++ b/sdks/php/src/Model/TeamMemberResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * TeamMemberResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class TeamMemberResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -79,6 +75,24 @@ class TeamMemberResponse implements ModelInterface, ArrayAccess, JsonSerializabl 'role' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'account_id' => false, + 'email_address' => false, + 'role' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -99,6 +113,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -177,39 +235,57 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['account_id'] = $data['account_id'] ?? null; - $this->container['email_address'] = $data['email_address'] ?? null; - $this->container['role'] = $data['role'] ?? null; + $this->setIfExists('account_id', $data ?? [], null); + $this->setIfExists('email_address', $data ?? [], null); + $this->setIfExists('role', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TeamMemberResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TeamMemberResponse { - /** @var TeamMemberResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TeamMemberResponse */ + return ObjectSerializer::deserialize( $data, TeamMemberResponse::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -219,9 +295,7 @@ public static function init(array $data): TeamMemberResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -254,6 +328,9 @@ public function getAccountId() */ public function setAccountId(?string $account_id) { + if (is_null($account_id)) { + throw new InvalidArgumentException('non-nullable account_id cannot be null'); + } $this->container['account_id'] = $account_id; return $this; @@ -278,6 +355,9 @@ public function getEmailAddress() */ public function setEmailAddress(?string $email_address) { + if (is_null($email_address)) { + throw new InvalidArgumentException('non-nullable email_address cannot be null'); + } $this->container['email_address'] = $email_address; return $this; @@ -302,6 +382,9 @@ public function getRole() */ public function setRole(?string $role) { + if (is_null($role)) { + throw new InvalidArgumentException('non-nullable role cannot be null'); + } $this->container['role'] = $role; return $this; @@ -310,12 +393,10 @@ public function setRole(?string $role) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -323,7 +404,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -336,13 +417,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -354,12 +433,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -368,8 +445,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TeamMembersResponse.php b/sdks/php/src/Model/TeamMembersResponse.php index 0c2d6f2f8..b3ac18575 100644 --- a/sdks/php/src/Model/TeamMembersResponse.php +++ b/sdks/php/src/Model/TeamMembersResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * TeamMembersResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class TeamMembersResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -79,6 +75,24 @@ class TeamMembersResponse implements ModelInterface, ArrayAccess, JsonSerializab 'warnings' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'team_members' => false, + 'list_info' => false, + 'warnings' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -99,6 +113,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -177,39 +235,57 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['team_members'] = $data['team_members'] ?? null; - $this->container['list_info'] = $data['list_info'] ?? null; - $this->container['warnings'] = $data['warnings'] ?? null; + $this->setIfExists('team_members', $data ?? [], null); + $this->setIfExists('list_info', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TeamMembersResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TeamMembersResponse { - /** @var TeamMembersResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TeamMembersResponse */ + return ObjectSerializer::deserialize( $data, TeamMembersResponse::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -219,9 +295,7 @@ public static function init(array $data): TeamMembersResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -254,6 +328,9 @@ public function getTeamMembers() */ public function setTeamMembers(?array $team_members) { + if (is_null($team_members)) { + throw new InvalidArgumentException('non-nullable team_members cannot be null'); + } $this->container['team_members'] = $team_members; return $this; @@ -278,6 +355,9 @@ public function getListInfo() */ public function setListInfo(?ListInfoResponse $list_info) { + if (is_null($list_info)) { + throw new InvalidArgumentException('non-nullable list_info cannot be null'); + } $this->container['list_info'] = $list_info; return $this; @@ -302,6 +382,9 @@ public function getWarnings() */ public function setWarnings(?array $warnings) { + if (is_null($warnings)) { + throw new InvalidArgumentException('non-nullable warnings cannot be null'); + } $this->container['warnings'] = $warnings; return $this; @@ -310,12 +393,10 @@ public function setWarnings(?array $warnings) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -323,7 +404,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -336,13 +417,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -354,12 +433,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -368,8 +445,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TeamParentResponse.php b/sdks/php/src/Model/TeamParentResponse.php index 36a50d9a8..d0d447285 100644 --- a/sdks/php/src/Model/TeamParentResponse.php +++ b/sdks/php/src/Model/TeamParentResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,12 +38,8 @@ * * @category Class * @description Information about the parent team if a team has one, set to `null` otherwise. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class TeamParentResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -78,6 +74,23 @@ class TeamParentResponse implements ModelInterface, ArrayAccess, JsonSerializabl 'name' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'team_id' => false, + 'name' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -98,6 +111,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -173,38 +230,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['team_id'] = $data['team_id'] ?? null; - $this->container['name'] = $data['name'] ?? null; + $this->setIfExists('team_id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TeamParentResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TeamParentResponse { - /** @var TeamParentResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TeamParentResponse */ + return ObjectSerializer::deserialize( $data, TeamParentResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -214,9 +289,7 @@ public static function init(array $data): TeamParentResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -249,6 +322,9 @@ public function getTeamId() */ public function setTeamId(?string $team_id) { + if (is_null($team_id)) { + throw new InvalidArgumentException('non-nullable team_id cannot be null'); + } $this->container['team_id'] = $team_id; return $this; @@ -273,6 +349,9 @@ public function getName() */ public function setName(?string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -281,12 +360,10 @@ public function setName(?string $name) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -294,7 +371,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -307,13 +384,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -325,12 +400,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -339,8 +412,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TeamRemoveMemberRequest.php b/sdks/php/src/Model/TeamRemoveMemberRequest.php index bb8bc2d34..6d7413255 100644 --- a/sdks/php/src/Model/TeamRemoveMemberRequest.php +++ b/sdks/php/src/Model/TeamRemoveMemberRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -38,11 +37,8 @@ * TeamRemoveMemberRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TeamRemoveMemberRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -83,6 +79,26 @@ class TeamRemoveMemberRequest implements ModelInterface, ArrayAccess, JsonSerial 'new_role' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'account_id' => false, + 'email_address' => false, + 'new_owner_email_address' => false, + 'new_team_id' => false, + 'new_role' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -103,6 +119,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -207,41 +267,59 @@ public function getNewRoleAllowableValues() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['account_id'] = $data['account_id'] ?? null; - $this->container['email_address'] = $data['email_address'] ?? null; - $this->container['new_owner_email_address'] = $data['new_owner_email_address'] ?? null; - $this->container['new_team_id'] = $data['new_team_id'] ?? null; - $this->container['new_role'] = $data['new_role'] ?? null; + $this->setIfExists('account_id', $data ?? [], null); + $this->setIfExists('email_address', $data ?? [], null); + $this->setIfExists('new_owner_email_address', $data ?? [], null); + $this->setIfExists('new_team_id', $data ?? [], null); + $this->setIfExists('new_role', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TeamRemoveMemberRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TeamRemoveMemberRequest { - /** @var TeamRemoveMemberRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TeamRemoveMemberRequest */ + return ObjectSerializer::deserialize( $data, TeamRemoveMemberRequest::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -295,6 +373,9 @@ public function getAccountId() */ public function setAccountId(?string $account_id) { + if (is_null($account_id)) { + throw new InvalidArgumentException('non-nullable account_id cannot be null'); + } $this->container['account_id'] = $account_id; return $this; @@ -319,6 +400,9 @@ public function getEmailAddress() */ public function setEmailAddress(?string $email_address) { + if (is_null($email_address)) { + throw new InvalidArgumentException('non-nullable email_address cannot be null'); + } $this->container['email_address'] = $email_address; return $this; @@ -343,6 +427,9 @@ public function getNewOwnerEmailAddress() */ public function setNewOwnerEmailAddress(?string $new_owner_email_address) { + if (is_null($new_owner_email_address)) { + throw new InvalidArgumentException('non-nullable new_owner_email_address cannot be null'); + } $this->container['new_owner_email_address'] = $new_owner_email_address; return $this; @@ -367,6 +454,9 @@ public function getNewTeamId() */ public function setNewTeamId(?string $new_team_id) { + if (is_null($new_team_id)) { + throw new InvalidArgumentException('non-nullable new_team_id cannot be null'); + } $this->container['new_team_id'] = $new_team_id; return $this; @@ -391,8 +481,11 @@ public function getNewRole() */ public function setNewRole(?string $new_role) { + if (is_null($new_role)) { + throw new InvalidArgumentException('non-nullable new_role cannot be null'); + } $allowedValues = $this->getNewRoleAllowableValues(); - if (!is_null($new_role) && !in_array($new_role, $allowedValues, true)) { + if (!in_array($new_role, $allowedValues, true)) { throw new InvalidArgumentException( sprintf( "Invalid value '%s' for 'new_role', must be one of '%s'", @@ -409,12 +502,10 @@ public function setNewRole(?string $new_role) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -422,7 +513,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -435,13 +526,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -453,12 +542,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -467,8 +554,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TeamResponse.php b/sdks/php/src/Model/TeamResponse.php index 5287609f0..402916a49 100644 --- a/sdks/php/src/Model/TeamResponse.php +++ b/sdks/php/src/Model/TeamResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,12 +38,8 @@ * * @category Class * @description Contains information about your team and its members - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class TeamResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -82,6 +78,25 @@ class TeamResponse implements ModelInterface, ArrayAccess, JsonSerializable 'invited_emails' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'name' => false, + 'accounts' => false, + 'invited_accounts' => false, + 'invited_emails' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -102,6 +117,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -183,40 +242,58 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['name'] = $data['name'] ?? null; - $this->container['accounts'] = $data['accounts'] ?? null; - $this->container['invited_accounts'] = $data['invited_accounts'] ?? null; - $this->container['invited_emails'] = $data['invited_emails'] ?? null; + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('accounts', $data ?? [], null); + $this->setIfExists('invited_accounts', $data ?? [], null); + $this->setIfExists('invited_emails', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TeamResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TeamResponse { - /** @var TeamResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TeamResponse */ + return ObjectSerializer::deserialize( $data, TeamResponse::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -226,9 +303,7 @@ public static function init(array $data): TeamResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -261,6 +336,9 @@ public function getName() */ public function setName(?string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -285,6 +363,9 @@ public function getAccounts() */ public function setAccounts(?array $accounts) { + if (is_null($accounts)) { + throw new InvalidArgumentException('non-nullable accounts cannot be null'); + } $this->container['accounts'] = $accounts; return $this; @@ -309,6 +390,9 @@ public function getInvitedAccounts() */ public function setInvitedAccounts(?array $invited_accounts) { + if (is_null($invited_accounts)) { + throw new InvalidArgumentException('non-nullable invited_accounts cannot be null'); + } $this->container['invited_accounts'] = $invited_accounts; return $this; @@ -333,6 +417,9 @@ public function getInvitedEmails() */ public function setInvitedEmails(?array $invited_emails) { + if (is_null($invited_emails)) { + throw new InvalidArgumentException('non-nullable invited_emails cannot be null'); + } $this->container['invited_emails'] = $invited_emails; return $this; @@ -341,12 +428,10 @@ public function setInvitedEmails(?array $invited_emails) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -354,7 +439,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -367,13 +452,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -385,12 +468,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -399,8 +480,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TeamSubTeamsResponse.php b/sdks/php/src/Model/TeamSubTeamsResponse.php index 3e9a646be..a1695e6a6 100644 --- a/sdks/php/src/Model/TeamSubTeamsResponse.php +++ b/sdks/php/src/Model/TeamSubTeamsResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * TeamSubTeamsResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class TeamSubTeamsResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -79,6 +75,24 @@ class TeamSubTeamsResponse implements ModelInterface, ArrayAccess, JsonSerializa 'warnings' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'sub_teams' => false, + 'list_info' => false, + 'warnings' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -99,6 +113,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -177,39 +235,57 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['sub_teams'] = $data['sub_teams'] ?? null; - $this->container['list_info'] = $data['list_info'] ?? null; - $this->container['warnings'] = $data['warnings'] ?? null; + $this->setIfExists('sub_teams', $data ?? [], null); + $this->setIfExists('list_info', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TeamSubTeamsResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TeamSubTeamsResponse { - /** @var TeamSubTeamsResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TeamSubTeamsResponse */ + return ObjectSerializer::deserialize( $data, TeamSubTeamsResponse::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -219,9 +295,7 @@ public static function init(array $data): TeamSubTeamsResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -254,6 +328,9 @@ public function getSubTeams() */ public function setSubTeams(?array $sub_teams) { + if (is_null($sub_teams)) { + throw new InvalidArgumentException('non-nullable sub_teams cannot be null'); + } $this->container['sub_teams'] = $sub_teams; return $this; @@ -278,6 +355,9 @@ public function getListInfo() */ public function setListInfo(?ListInfoResponse $list_info) { + if (is_null($list_info)) { + throw new InvalidArgumentException('non-nullable list_info cannot be null'); + } $this->container['list_info'] = $list_info; return $this; @@ -302,6 +382,9 @@ public function getWarnings() */ public function setWarnings(?array $warnings) { + if (is_null($warnings)) { + throw new InvalidArgumentException('non-nullable warnings cannot be null'); + } $this->container['warnings'] = $warnings; return $this; @@ -310,12 +393,10 @@ public function setWarnings(?array $warnings) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -323,7 +404,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -336,13 +417,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -354,12 +433,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -368,8 +445,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TeamUpdateRequest.php b/sdks/php/src/Model/TeamUpdateRequest.php index 08f5760dc..6606b7676 100644 --- a/sdks/php/src/Model/TeamUpdateRequest.php +++ b/sdks/php/src/Model/TeamUpdateRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * TeamUpdateRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TeamUpdateRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -74,6 +71,22 @@ class TeamUpdateRequest implements ModelInterface, ArrayAccess, JsonSerializable 'name' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'name' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -94,6 +107,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -166,37 +223,55 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['name'] = $data['name'] ?? null; + $this->setIfExists('name', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TeamUpdateRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TeamUpdateRequest { - /** @var TeamUpdateRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TeamUpdateRequest */ + return ObjectSerializer::deserialize( $data, TeamUpdateRequest::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -206,9 +281,7 @@ public static function init(array $data): TeamUpdateRequest */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -241,6 +314,9 @@ public function getName() */ public function setName(?string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -249,12 +325,10 @@ public function setName(?string $name) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -262,7 +336,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -275,13 +349,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -293,12 +365,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -307,8 +377,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateAddUserRequest.php b/sdks/php/src/Model/TemplateAddUserRequest.php index eb131d57b..ea87103ad 100644 --- a/sdks/php/src/Model/TemplateAddUserRequest.php +++ b/sdks/php/src/Model/TemplateAddUserRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * TemplateAddUserRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TemplateAddUserRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -78,6 +75,24 @@ class TemplateAddUserRequest implements ModelInterface, ArrayAccess, JsonSeriali 'skip_notification' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'account_id' => false, + 'email_address' => false, + 'skip_notification' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -98,6 +113,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -176,39 +235,57 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['account_id'] = $data['account_id'] ?? null; - $this->container['email_address'] = $data['email_address'] ?? null; - $this->container['skip_notification'] = $data['skip_notification'] ?? false; + $this->setIfExists('account_id', $data ?? [], null); + $this->setIfExists('email_address', $data ?? [], null); + $this->setIfExists('skip_notification', $data ?? [], false); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateAddUserRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateAddUserRequest { - /** @var TemplateAddUserRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateAddUserRequest */ + return ObjectSerializer::deserialize( $data, TemplateAddUserRequest::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -218,9 +295,7 @@ public static function init(array $data): TemplateAddUserRequest */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -253,6 +328,9 @@ public function getAccountId() */ public function setAccountId(?string $account_id) { + if (is_null($account_id)) { + throw new InvalidArgumentException('non-nullable account_id cannot be null'); + } $this->container['account_id'] = $account_id; return $this; @@ -277,6 +355,9 @@ public function getEmailAddress() */ public function setEmailAddress(?string $email_address) { + if (is_null($email_address)) { + throw new InvalidArgumentException('non-nullable email_address cannot be null'); + } $this->container['email_address'] = $email_address; return $this; @@ -301,6 +382,9 @@ public function getSkipNotification() */ public function setSkipNotification(?bool $skip_notification) { + if (is_null($skip_notification)) { + throw new InvalidArgumentException('non-nullable skip_notification cannot be null'); + } $this->container['skip_notification'] = $skip_notification; return $this; @@ -309,12 +393,10 @@ public function setSkipNotification(?bool $skip_notification) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -322,7 +404,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -335,13 +417,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -353,12 +433,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -367,8 +445,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateCreateEmbeddedDraftRequest.php b/sdks/php/src/Model/TemplateCreateEmbeddedDraftRequest.php index 83b3dcd3a..fe626a83a 100644 --- a/sdks/php/src/Model/TemplateCreateEmbeddedDraftRequest.php +++ b/sdks/php/src/Model/TemplateCreateEmbeddedDraftRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -39,11 +38,8 @@ * TemplateCreateEmbeddedDraftRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TemplateCreateEmbeddedDraftRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -124,6 +120,46 @@ class TemplateCreateEmbeddedDraftRequest implements ModelInterface, ArrayAccess, 'use_preexisting_fields' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'client_id' => false, + 'files' => false, + 'file_urls' => false, + 'allow_ccs' => false, + 'allow_reassign' => false, + 'attachments' => false, + 'cc_roles' => false, + 'editor_options' => false, + 'field_options' => false, + 'force_signer_roles' => false, + 'force_subject_message' => false, + 'form_field_groups' => false, + 'form_field_rules' => false, + 'form_fields_per_document' => false, + 'merge_fields' => false, + 'message' => false, + 'metadata' => false, + 'show_preview' => false, + 'show_progress_stepper' => false, + 'signer_roles' => false, + 'skip_me_now' => false, + 'subject' => false, + 'test_mode' => false, + 'title' => false, + 'use_preexisting_fields' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -144,6 +180,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -288,61 +368,79 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['client_id'] = $data['client_id'] ?? null; - $this->container['files'] = $data['files'] ?? null; - $this->container['file_urls'] = $data['file_urls'] ?? null; - $this->container['allow_ccs'] = $data['allow_ccs'] ?? true; - $this->container['allow_reassign'] = $data['allow_reassign'] ?? false; - $this->container['attachments'] = $data['attachments'] ?? null; - $this->container['cc_roles'] = $data['cc_roles'] ?? null; - $this->container['editor_options'] = $data['editor_options'] ?? null; - $this->container['field_options'] = $data['field_options'] ?? null; - $this->container['force_signer_roles'] = $data['force_signer_roles'] ?? false; - $this->container['force_subject_message'] = $data['force_subject_message'] ?? false; - $this->container['form_field_groups'] = $data['form_field_groups'] ?? null; - $this->container['form_field_rules'] = $data['form_field_rules'] ?? null; - $this->container['form_fields_per_document'] = $data['form_fields_per_document'] ?? null; - $this->container['merge_fields'] = $data['merge_fields'] ?? null; - $this->container['message'] = $data['message'] ?? null; - $this->container['metadata'] = $data['metadata'] ?? null; - $this->container['show_preview'] = $data['show_preview'] ?? false; - $this->container['show_progress_stepper'] = $data['show_progress_stepper'] ?? true; - $this->container['signer_roles'] = $data['signer_roles'] ?? null; - $this->container['skip_me_now'] = $data['skip_me_now'] ?? false; - $this->container['subject'] = $data['subject'] ?? null; - $this->container['test_mode'] = $data['test_mode'] ?? false; - $this->container['title'] = $data['title'] ?? null; - $this->container['use_preexisting_fields'] = $data['use_preexisting_fields'] ?? false; - } - - /** @deprecated use ::init() */ + $this->setIfExists('client_id', $data ?? [], null); + $this->setIfExists('files', $data ?? [], null); + $this->setIfExists('file_urls', $data ?? [], null); + $this->setIfExists('allow_ccs', $data ?? [], true); + $this->setIfExists('allow_reassign', $data ?? [], false); + $this->setIfExists('attachments', $data ?? [], null); + $this->setIfExists('cc_roles', $data ?? [], null); + $this->setIfExists('editor_options', $data ?? [], null); + $this->setIfExists('field_options', $data ?? [], null); + $this->setIfExists('force_signer_roles', $data ?? [], false); + $this->setIfExists('force_subject_message', $data ?? [], false); + $this->setIfExists('form_field_groups', $data ?? [], null); + $this->setIfExists('form_field_rules', $data ?? [], null); + $this->setIfExists('form_fields_per_document', $data ?? [], null); + $this->setIfExists('merge_fields', $data ?? [], null); + $this->setIfExists('message', $data ?? [], null); + $this->setIfExists('metadata', $data ?? [], null); + $this->setIfExists('show_preview', $data ?? [], false); + $this->setIfExists('show_progress_stepper', $data ?? [], true); + $this->setIfExists('signer_roles', $data ?? [], null); + $this->setIfExists('skip_me_now', $data ?? [], false); + $this->setIfExists('subject', $data ?? [], null); + $this->setIfExists('test_mode', $data ?? [], false); + $this->setIfExists('title', $data ?? [], null); + $this->setIfExists('use_preexisting_fields', $data ?? [], false); + } + + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateCreateEmbeddedDraftRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateCreateEmbeddedDraftRequest { - /** @var TemplateCreateEmbeddedDraftRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateCreateEmbeddedDraftRequest */ + return ObjectSerializer::deserialize( $data, TemplateCreateEmbeddedDraftRequest::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -398,6 +496,9 @@ public function getClientId() */ public function setClientId(string $client_id) { + if (is_null($client_id)) { + throw new InvalidArgumentException('non-nullable client_id cannot be null'); + } $this->container['client_id'] = $client_id; return $this; @@ -422,6 +523,9 @@ public function getFiles() */ public function setFiles(?array $files) { + if (is_null($files)) { + throw new InvalidArgumentException('non-nullable files cannot be null'); + } $this->container['files'] = $files; return $this; @@ -446,6 +550,9 @@ public function getFileUrls() */ public function setFileUrls(?array $file_urls) { + if (is_null($file_urls)) { + throw new InvalidArgumentException('non-nullable file_urls cannot be null'); + } $this->container['file_urls'] = $file_urls; return $this; @@ -470,6 +577,9 @@ public function getAllowCcs() */ public function setAllowCcs(?bool $allow_ccs) { + if (is_null($allow_ccs)) { + throw new InvalidArgumentException('non-nullable allow_ccs cannot be null'); + } $this->container['allow_ccs'] = $allow_ccs; return $this; @@ -494,6 +604,9 @@ public function getAllowReassign() */ public function setAllowReassign(?bool $allow_reassign) { + if (is_null($allow_reassign)) { + throw new InvalidArgumentException('non-nullable allow_reassign cannot be null'); + } $this->container['allow_reassign'] = $allow_reassign; return $this; @@ -518,6 +631,9 @@ public function getAttachments() */ public function setAttachments(?array $attachments) { + if (is_null($attachments)) { + throw new InvalidArgumentException('non-nullable attachments cannot be null'); + } $this->container['attachments'] = $attachments; return $this; @@ -542,6 +658,9 @@ public function getCcRoles() */ public function setCcRoles(?array $cc_roles) { + if (is_null($cc_roles)) { + throw new InvalidArgumentException('non-nullable cc_roles cannot be null'); + } $this->container['cc_roles'] = $cc_roles; return $this; @@ -566,6 +685,9 @@ public function getEditorOptions() */ public function setEditorOptions(?SubEditorOptions $editor_options) { + if (is_null($editor_options)) { + throw new InvalidArgumentException('non-nullable editor_options cannot be null'); + } $this->container['editor_options'] = $editor_options; return $this; @@ -590,6 +712,9 @@ public function getFieldOptions() */ public function setFieldOptions(?SubFieldOptions $field_options) { + if (is_null($field_options)) { + throw new InvalidArgumentException('non-nullable field_options cannot be null'); + } $this->container['field_options'] = $field_options; return $this; @@ -614,6 +739,9 @@ public function getForceSignerRoles() */ public function setForceSignerRoles(?bool $force_signer_roles) { + if (is_null($force_signer_roles)) { + throw new InvalidArgumentException('non-nullable force_signer_roles cannot be null'); + } $this->container['force_signer_roles'] = $force_signer_roles; return $this; @@ -638,6 +766,9 @@ public function getForceSubjectMessage() */ public function setForceSubjectMessage(?bool $force_subject_message) { + if (is_null($force_subject_message)) { + throw new InvalidArgumentException('non-nullable force_subject_message cannot be null'); + } $this->container['force_subject_message'] = $force_subject_message; return $this; @@ -662,6 +793,9 @@ public function getFormFieldGroups() */ public function setFormFieldGroups(?array $form_field_groups) { + if (is_null($form_field_groups)) { + throw new InvalidArgumentException('non-nullable form_field_groups cannot be null'); + } $this->container['form_field_groups'] = $form_field_groups; return $this; @@ -686,6 +820,9 @@ public function getFormFieldRules() */ public function setFormFieldRules(?array $form_field_rules) { + if (is_null($form_field_rules)) { + throw new InvalidArgumentException('non-nullable form_field_rules cannot be null'); + } $this->container['form_field_rules'] = $form_field_rules; return $this; @@ -710,6 +847,9 @@ public function getFormFieldsPerDocument() */ public function setFormFieldsPerDocument(?array $form_fields_per_document) { + if (is_null($form_fields_per_document)) { + throw new InvalidArgumentException('non-nullable form_fields_per_document cannot be null'); + } $this->container['form_fields_per_document'] = $form_fields_per_document; return $this; @@ -734,6 +874,9 @@ public function getMergeFields() */ public function setMergeFields(?array $merge_fields) { + if (is_null($merge_fields)) { + throw new InvalidArgumentException('non-nullable merge_fields cannot be null'); + } $this->container['merge_fields'] = $merge_fields; return $this; @@ -758,7 +901,10 @@ public function getMessage() */ public function setMessage(?string $message) { - if (!is_null($message) && (mb_strlen($message) > 5000)) { + if (is_null($message)) { + throw new InvalidArgumentException('non-nullable message cannot be null'); + } + if (mb_strlen($message) > 5000) { throw new InvalidArgumentException('invalid length for $message when calling TemplateCreateEmbeddedDraftRequest., must be smaller than or equal to 5000.'); } @@ -786,6 +932,10 @@ public function getMetadata() */ public function setMetadata(?array $metadata) { + if (is_null($metadata)) { + throw new InvalidArgumentException('non-nullable metadata cannot be null'); + } + $this->container['metadata'] = $metadata; return $this; @@ -810,6 +960,9 @@ public function getShowPreview() */ public function setShowPreview(?bool $show_preview) { + if (is_null($show_preview)) { + throw new InvalidArgumentException('non-nullable show_preview cannot be null'); + } $this->container['show_preview'] = $show_preview; return $this; @@ -834,6 +987,9 @@ public function getShowProgressStepper() */ public function setShowProgressStepper(?bool $show_progress_stepper) { + if (is_null($show_progress_stepper)) { + throw new InvalidArgumentException('non-nullable show_progress_stepper cannot be null'); + } $this->container['show_progress_stepper'] = $show_progress_stepper; return $this; @@ -858,6 +1014,9 @@ public function getSignerRoles() */ public function setSignerRoles(?array $signer_roles) { + if (is_null($signer_roles)) { + throw new InvalidArgumentException('non-nullable signer_roles cannot be null'); + } $this->container['signer_roles'] = $signer_roles; return $this; @@ -882,6 +1041,9 @@ public function getSkipMeNow() */ public function setSkipMeNow(?bool $skip_me_now) { + if (is_null($skip_me_now)) { + throw new InvalidArgumentException('non-nullable skip_me_now cannot be null'); + } $this->container['skip_me_now'] = $skip_me_now; return $this; @@ -906,7 +1068,10 @@ public function getSubject() */ public function setSubject(?string $subject) { - if (!is_null($subject) && (mb_strlen($subject) > 200)) { + if (is_null($subject)) { + throw new InvalidArgumentException('non-nullable subject cannot be null'); + } + if (mb_strlen($subject) > 200) { throw new InvalidArgumentException('invalid length for $subject when calling TemplateCreateEmbeddedDraftRequest., must be smaller than or equal to 200.'); } @@ -934,6 +1099,9 @@ public function getTestMode() */ public function setTestMode(?bool $test_mode) { + if (is_null($test_mode)) { + throw new InvalidArgumentException('non-nullable test_mode cannot be null'); + } $this->container['test_mode'] = $test_mode; return $this; @@ -958,6 +1126,9 @@ public function getTitle() */ public function setTitle(?string $title) { + if (is_null($title)) { + throw new InvalidArgumentException('non-nullable title cannot be null'); + } $this->container['title'] = $title; return $this; @@ -982,6 +1153,9 @@ public function getUsePreexistingFields() */ public function setUsePreexistingFields(?bool $use_preexisting_fields) { + if (is_null($use_preexisting_fields)) { + throw new InvalidArgumentException('non-nullable use_preexisting_fields cannot be null'); + } $this->container['use_preexisting_fields'] = $use_preexisting_fields; return $this; @@ -990,12 +1164,10 @@ public function setUsePreexistingFields(?bool $use_preexisting_fields) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -1003,7 +1175,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -1016,13 +1188,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -1034,12 +1204,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -1048,8 +1216,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateCreateEmbeddedDraftResponse.php b/sdks/php/src/Model/TemplateCreateEmbeddedDraftResponse.php index beec359d5..6ac000d9f 100644 --- a/sdks/php/src/Model/TemplateCreateEmbeddedDraftResponse.php +++ b/sdks/php/src/Model/TemplateCreateEmbeddedDraftResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * TemplateCreateEmbeddedDraftResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class TemplateCreateEmbeddedDraftResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -77,6 +73,23 @@ class TemplateCreateEmbeddedDraftResponse implements ModelInterface, ArrayAccess 'warnings' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'template' => false, + 'warnings' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -97,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -172,38 +229,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['template'] = $data['template'] ?? null; - $this->container['warnings'] = $data['warnings'] ?? null; + $this->setIfExists('template', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateCreateEmbeddedDraftResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateCreateEmbeddedDraftResponse { - /** @var TemplateCreateEmbeddedDraftResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateCreateEmbeddedDraftResponse */ + return ObjectSerializer::deserialize( $data, TemplateCreateEmbeddedDraftResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -213,9 +288,7 @@ public static function init(array $data): TemplateCreateEmbeddedDraftResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -248,6 +321,9 @@ public function getTemplate() */ public function setTemplate(?TemplateCreateEmbeddedDraftResponseTemplate $template) { + if (is_null($template)) { + throw new InvalidArgumentException('non-nullable template cannot be null'); + } $this->container['template'] = $template; return $this; @@ -272,6 +348,9 @@ public function getWarnings() */ public function setWarnings(?array $warnings) { + if (is_null($warnings)) { + throw new InvalidArgumentException('non-nullable warnings cannot be null'); + } $this->container['warnings'] = $warnings; return $this; @@ -280,12 +359,10 @@ public function setWarnings(?array $warnings) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -293,7 +370,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -306,13 +383,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -324,12 +399,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -338,8 +411,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateCreateEmbeddedDraftResponseTemplate.php b/sdks/php/src/Model/TemplateCreateEmbeddedDraftResponseTemplate.php index b8ab59bc6..44031ce16 100644 --- a/sdks/php/src/Model/TemplateCreateEmbeddedDraftResponseTemplate.php +++ b/sdks/php/src/Model/TemplateCreateEmbeddedDraftResponseTemplate.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,12 +38,8 @@ * * @category Class * @description Template object with parameters: `template_id`, `edit_url`, `expires_at`. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class TemplateCreateEmbeddedDraftResponseTemplate implements ModelInterface, ArrayAccess, JsonSerializable { @@ -82,6 +78,25 @@ class TemplateCreateEmbeddedDraftResponseTemplate implements ModelInterface, Arr 'warnings' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'template_id' => false, + 'edit_url' => false, + 'expires_at' => false, + 'warnings' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -102,6 +117,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -183,40 +242,58 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['template_id'] = $data['template_id'] ?? null; - $this->container['edit_url'] = $data['edit_url'] ?? null; - $this->container['expires_at'] = $data['expires_at'] ?? null; - $this->container['warnings'] = $data['warnings'] ?? null; + $this->setIfExists('template_id', $data ?? [], null); + $this->setIfExists('edit_url', $data ?? [], null); + $this->setIfExists('expires_at', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateCreateEmbeddedDraftResponseTemplate { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateCreateEmbeddedDraftResponseTemplate { - /** @var TemplateCreateEmbeddedDraftResponseTemplate $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateCreateEmbeddedDraftResponseTemplate */ + return ObjectSerializer::deserialize( $data, TemplateCreateEmbeddedDraftResponseTemplate::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -226,9 +303,7 @@ public static function init(array $data): TemplateCreateEmbeddedDraftResponseTem */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -261,6 +336,9 @@ public function getTemplateId() */ public function setTemplateId(?string $template_id) { + if (is_null($template_id)) { + throw new InvalidArgumentException('non-nullable template_id cannot be null'); + } $this->container['template_id'] = $template_id; return $this; @@ -285,6 +363,9 @@ public function getEditUrl() */ public function setEditUrl(?string $edit_url) { + if (is_null($edit_url)) { + throw new InvalidArgumentException('non-nullable edit_url cannot be null'); + } $this->container['edit_url'] = $edit_url; return $this; @@ -309,6 +390,9 @@ public function getExpiresAt() */ public function setExpiresAt(?int $expires_at) { + if (is_null($expires_at)) { + throw new InvalidArgumentException('non-nullable expires_at cannot be null'); + } $this->container['expires_at'] = $expires_at; return $this; @@ -335,6 +419,9 @@ public function getWarnings() */ public function setWarnings(?array $warnings) { + if (is_null($warnings)) { + throw new InvalidArgumentException('non-nullable warnings cannot be null'); + } $this->container['warnings'] = $warnings; return $this; @@ -343,12 +430,10 @@ public function setWarnings(?array $warnings) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -356,7 +441,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -369,13 +454,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -387,12 +470,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -401,8 +482,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateCreateRequest.php b/sdks/php/src/Model/TemplateCreateRequest.php index 2e9fe0901..ec6890622 100644 --- a/sdks/php/src/Model/TemplateCreateRequest.php +++ b/sdks/php/src/Model/TemplateCreateRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -39,11 +38,8 @@ * TemplateCreateRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TemplateCreateRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -110,6 +106,39 @@ class TemplateCreateRequest implements ModelInterface, ArrayAccess, JsonSerializ 'use_preexisting_fields' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'form_fields_per_document' => false, + 'signer_roles' => false, + 'files' => false, + 'file_urls' => false, + 'allow_reassign' => false, + 'attachments' => false, + 'cc_roles' => false, + 'client_id' => false, + 'field_options' => false, + 'form_field_groups' => false, + 'form_field_rules' => false, + 'merge_fields' => false, + 'message' => false, + 'metadata' => false, + 'subject' => false, + 'test_mode' => false, + 'title' => false, + 'use_preexisting_fields' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -130,6 +159,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -253,54 +326,72 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['form_fields_per_document'] = $data['form_fields_per_document'] ?? null; - $this->container['signer_roles'] = $data['signer_roles'] ?? null; - $this->container['files'] = $data['files'] ?? null; - $this->container['file_urls'] = $data['file_urls'] ?? null; - $this->container['allow_reassign'] = $data['allow_reassign'] ?? false; - $this->container['attachments'] = $data['attachments'] ?? null; - $this->container['cc_roles'] = $data['cc_roles'] ?? null; - $this->container['client_id'] = $data['client_id'] ?? null; - $this->container['field_options'] = $data['field_options'] ?? null; - $this->container['form_field_groups'] = $data['form_field_groups'] ?? null; - $this->container['form_field_rules'] = $data['form_field_rules'] ?? null; - $this->container['merge_fields'] = $data['merge_fields'] ?? null; - $this->container['message'] = $data['message'] ?? null; - $this->container['metadata'] = $data['metadata'] ?? null; - $this->container['subject'] = $data['subject'] ?? null; - $this->container['test_mode'] = $data['test_mode'] ?? false; - $this->container['title'] = $data['title'] ?? null; - $this->container['use_preexisting_fields'] = $data['use_preexisting_fields'] ?? false; - } - - /** @deprecated use ::init() */ + $this->setIfExists('form_fields_per_document', $data ?? [], null); + $this->setIfExists('signer_roles', $data ?? [], null); + $this->setIfExists('files', $data ?? [], null); + $this->setIfExists('file_urls', $data ?? [], null); + $this->setIfExists('allow_reassign', $data ?? [], false); + $this->setIfExists('attachments', $data ?? [], null); + $this->setIfExists('cc_roles', $data ?? [], null); + $this->setIfExists('client_id', $data ?? [], null); + $this->setIfExists('field_options', $data ?? [], null); + $this->setIfExists('form_field_groups', $data ?? [], null); + $this->setIfExists('form_field_rules', $data ?? [], null); + $this->setIfExists('merge_fields', $data ?? [], null); + $this->setIfExists('message', $data ?? [], null); + $this->setIfExists('metadata', $data ?? [], null); + $this->setIfExists('subject', $data ?? [], null); + $this->setIfExists('test_mode', $data ?? [], false); + $this->setIfExists('title', $data ?? [], null); + $this->setIfExists('use_preexisting_fields', $data ?? [], false); + } + + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateCreateRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateCreateRequest { - /** @var TemplateCreateRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateCreateRequest */ + return ObjectSerializer::deserialize( $data, TemplateCreateRequest::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -359,6 +450,9 @@ public function getFormFieldsPerDocument() */ public function setFormFieldsPerDocument(array $form_fields_per_document) { + if (is_null($form_fields_per_document)) { + throw new InvalidArgumentException('non-nullable form_fields_per_document cannot be null'); + } $this->container['form_fields_per_document'] = $form_fields_per_document; return $this; @@ -383,6 +477,9 @@ public function getSignerRoles() */ public function setSignerRoles(array $signer_roles) { + if (is_null($signer_roles)) { + throw new InvalidArgumentException('non-nullable signer_roles cannot be null'); + } $this->container['signer_roles'] = $signer_roles; return $this; @@ -407,6 +504,9 @@ public function getFiles() */ public function setFiles(?array $files) { + if (is_null($files)) { + throw new InvalidArgumentException('non-nullable files cannot be null'); + } $this->container['files'] = $files; return $this; @@ -431,6 +531,9 @@ public function getFileUrls() */ public function setFileUrls(?array $file_urls) { + if (is_null($file_urls)) { + throw new InvalidArgumentException('non-nullable file_urls cannot be null'); + } $this->container['file_urls'] = $file_urls; return $this; @@ -455,6 +558,9 @@ public function getAllowReassign() */ public function setAllowReassign(?bool $allow_reassign) { + if (is_null($allow_reassign)) { + throw new InvalidArgumentException('non-nullable allow_reassign cannot be null'); + } $this->container['allow_reassign'] = $allow_reassign; return $this; @@ -479,6 +585,9 @@ public function getAttachments() */ public function setAttachments(?array $attachments) { + if (is_null($attachments)) { + throw new InvalidArgumentException('non-nullable attachments cannot be null'); + } $this->container['attachments'] = $attachments; return $this; @@ -503,6 +612,9 @@ public function getCcRoles() */ public function setCcRoles(?array $cc_roles) { + if (is_null($cc_roles)) { + throw new InvalidArgumentException('non-nullable cc_roles cannot be null'); + } $this->container['cc_roles'] = $cc_roles; return $this; @@ -527,6 +639,9 @@ public function getClientId() */ public function setClientId(?string $client_id) { + if (is_null($client_id)) { + throw new InvalidArgumentException('non-nullable client_id cannot be null'); + } $this->container['client_id'] = $client_id; return $this; @@ -551,6 +666,9 @@ public function getFieldOptions() */ public function setFieldOptions(?SubFieldOptions $field_options) { + if (is_null($field_options)) { + throw new InvalidArgumentException('non-nullable field_options cannot be null'); + } $this->container['field_options'] = $field_options; return $this; @@ -575,6 +693,9 @@ public function getFormFieldGroups() */ public function setFormFieldGroups(?array $form_field_groups) { + if (is_null($form_field_groups)) { + throw new InvalidArgumentException('non-nullable form_field_groups cannot be null'); + } $this->container['form_field_groups'] = $form_field_groups; return $this; @@ -599,6 +720,9 @@ public function getFormFieldRules() */ public function setFormFieldRules(?array $form_field_rules) { + if (is_null($form_field_rules)) { + throw new InvalidArgumentException('non-nullable form_field_rules cannot be null'); + } $this->container['form_field_rules'] = $form_field_rules; return $this; @@ -623,6 +747,9 @@ public function getMergeFields() */ public function setMergeFields(?array $merge_fields) { + if (is_null($merge_fields)) { + throw new InvalidArgumentException('non-nullable merge_fields cannot be null'); + } $this->container['merge_fields'] = $merge_fields; return $this; @@ -647,7 +774,10 @@ public function getMessage() */ public function setMessage(?string $message) { - if (!is_null($message) && (mb_strlen($message) > 5000)) { + if (is_null($message)) { + throw new InvalidArgumentException('non-nullable message cannot be null'); + } + if (mb_strlen($message) > 5000) { throw new InvalidArgumentException('invalid length for $message when calling TemplateCreateRequest., must be smaller than or equal to 5000.'); } @@ -675,6 +805,10 @@ public function getMetadata() */ public function setMetadata(?array $metadata) { + if (is_null($metadata)) { + throw new InvalidArgumentException('non-nullable metadata cannot be null'); + } + $this->container['metadata'] = $metadata; return $this; @@ -699,7 +833,10 @@ public function getSubject() */ public function setSubject(?string $subject) { - if (!is_null($subject) && (mb_strlen($subject) > 200)) { + if (is_null($subject)) { + throw new InvalidArgumentException('non-nullable subject cannot be null'); + } + if (mb_strlen($subject) > 200) { throw new InvalidArgumentException('invalid length for $subject when calling TemplateCreateRequest., must be smaller than or equal to 200.'); } @@ -727,6 +864,9 @@ public function getTestMode() */ public function setTestMode(?bool $test_mode) { + if (is_null($test_mode)) { + throw new InvalidArgumentException('non-nullable test_mode cannot be null'); + } $this->container['test_mode'] = $test_mode; return $this; @@ -751,6 +891,9 @@ public function getTitle() */ public function setTitle(?string $title) { + if (is_null($title)) { + throw new InvalidArgumentException('non-nullable title cannot be null'); + } $this->container['title'] = $title; return $this; @@ -775,6 +918,9 @@ public function getUsePreexistingFields() */ public function setUsePreexistingFields(?bool $use_preexisting_fields) { + if (is_null($use_preexisting_fields)) { + throw new InvalidArgumentException('non-nullable use_preexisting_fields cannot be null'); + } $this->container['use_preexisting_fields'] = $use_preexisting_fields; return $this; @@ -783,12 +929,10 @@ public function setUsePreexistingFields(?bool $use_preexisting_fields) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -796,7 +940,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -809,13 +953,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -827,12 +969,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -841,8 +981,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateCreateResponse.php b/sdks/php/src/Model/TemplateCreateResponse.php index 2d4a1f236..cd1be57e4 100644 --- a/sdks/php/src/Model/TemplateCreateResponse.php +++ b/sdks/php/src/Model/TemplateCreateResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * TemplateCreateResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class TemplateCreateResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -77,6 +73,23 @@ class TemplateCreateResponse implements ModelInterface, ArrayAccess, JsonSeriali 'warnings' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'template' => false, + 'warnings' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -97,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -172,38 +229,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['template'] = $data['template'] ?? null; - $this->container['warnings'] = $data['warnings'] ?? null; + $this->setIfExists('template', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateCreateResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateCreateResponse { - /** @var TemplateCreateResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateCreateResponse */ + return ObjectSerializer::deserialize( $data, TemplateCreateResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -213,9 +288,7 @@ public static function init(array $data): TemplateCreateResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -248,6 +321,9 @@ public function getTemplate() */ public function setTemplate(?TemplateCreateResponseTemplate $template) { + if (is_null($template)) { + throw new InvalidArgumentException('non-nullable template cannot be null'); + } $this->container['template'] = $template; return $this; @@ -272,6 +348,9 @@ public function getWarnings() */ public function setWarnings(?array $warnings) { + if (is_null($warnings)) { + throw new InvalidArgumentException('non-nullable warnings cannot be null'); + } $this->container['warnings'] = $warnings; return $this; @@ -280,12 +359,10 @@ public function setWarnings(?array $warnings) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -293,7 +370,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -306,13 +383,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -324,12 +399,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -338,8 +411,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateCreateResponseTemplate.php b/sdks/php/src/Model/TemplateCreateResponseTemplate.php index 1c98865dc..199aa3f74 100644 --- a/sdks/php/src/Model/TemplateCreateResponseTemplate.php +++ b/sdks/php/src/Model/TemplateCreateResponseTemplate.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,12 +38,8 @@ * * @category Class * @description Template object with parameters: `template_id`. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class TemplateCreateResponseTemplate implements ModelInterface, ArrayAccess, JsonSerializable { @@ -76,6 +72,22 @@ class TemplateCreateResponseTemplate implements ModelInterface, ArrayAccess, Jso 'template_id' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'template_id' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -96,6 +108,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -168,37 +224,55 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['template_id'] = $data['template_id'] ?? null; + $this->setIfExists('template_id', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateCreateResponseTemplate { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateCreateResponseTemplate { - /** @var TemplateCreateResponseTemplate $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateCreateResponseTemplate */ + return ObjectSerializer::deserialize( $data, TemplateCreateResponseTemplate::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -208,9 +282,7 @@ public static function init(array $data): TemplateCreateResponseTemplate */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -243,6 +315,9 @@ public function getTemplateId() */ public function setTemplateId(?string $template_id) { + if (is_null($template_id)) { + throw new InvalidArgumentException('non-nullable template_id cannot be null'); + } $this->container['template_id'] = $template_id; return $this; @@ -251,12 +326,10 @@ public function setTemplateId(?string $template_id) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -264,7 +337,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -277,13 +350,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -295,12 +366,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -309,8 +378,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateEditResponse.php b/sdks/php/src/Model/TemplateEditResponse.php index 455533dd7..5a888bfb2 100644 --- a/sdks/php/src/Model/TemplateEditResponse.php +++ b/sdks/php/src/Model/TemplateEditResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * TemplateEditResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TemplateEditResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -74,6 +71,22 @@ class TemplateEditResponse implements ModelInterface, ArrayAccess, JsonSerializa 'template_id' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'template_id' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -94,6 +107,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -166,37 +223,55 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['template_id'] = $data['template_id'] ?? null; + $this->setIfExists('template_id', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateEditResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateEditResponse { - /** @var TemplateEditResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateEditResponse */ + return ObjectSerializer::deserialize( $data, TemplateEditResponse::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -206,9 +281,7 @@ public static function init(array $data): TemplateEditResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -241,6 +314,9 @@ public function getTemplateId() */ public function setTemplateId(?string $template_id) { + if (is_null($template_id)) { + throw new InvalidArgumentException('non-nullable template_id cannot be null'); + } $this->container['template_id'] = $template_id; return $this; @@ -249,12 +325,10 @@ public function setTemplateId(?string $template_id) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -262,7 +336,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -275,13 +349,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -293,12 +365,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -307,8 +377,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateGetResponse.php b/sdks/php/src/Model/TemplateGetResponse.php index 340a002f2..c2a087334 100644 --- a/sdks/php/src/Model/TemplateGetResponse.php +++ b/sdks/php/src/Model/TemplateGetResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * TemplateGetResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class TemplateGetResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -77,6 +73,23 @@ class TemplateGetResponse implements ModelInterface, ArrayAccess, JsonSerializab 'warnings' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'template' => false, + 'warnings' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -97,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -172,38 +229,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['template'] = $data['template'] ?? null; - $this->container['warnings'] = $data['warnings'] ?? null; + $this->setIfExists('template', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateGetResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateGetResponse { - /** @var TemplateGetResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateGetResponse */ + return ObjectSerializer::deserialize( $data, TemplateGetResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -213,9 +288,7 @@ public static function init(array $data): TemplateGetResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -248,6 +321,9 @@ public function getTemplate() */ public function setTemplate(?TemplateResponse $template) { + if (is_null($template)) { + throw new InvalidArgumentException('non-nullable template cannot be null'); + } $this->container['template'] = $template; return $this; @@ -272,6 +348,9 @@ public function getWarnings() */ public function setWarnings(?array $warnings) { + if (is_null($warnings)) { + throw new InvalidArgumentException('non-nullable warnings cannot be null'); + } $this->container['warnings'] = $warnings; return $this; @@ -280,12 +359,10 @@ public function setWarnings(?array $warnings) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -293,7 +370,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -306,13 +383,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -324,12 +399,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -338,8 +411,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateListResponse.php b/sdks/php/src/Model/TemplateListResponse.php index 3ff89da3c..45a2fe1a4 100644 --- a/sdks/php/src/Model/TemplateListResponse.php +++ b/sdks/php/src/Model/TemplateListResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * TemplateListResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class TemplateListResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -79,6 +75,24 @@ class TemplateListResponse implements ModelInterface, ArrayAccess, JsonSerializa 'warnings' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'templates' => false, + 'list_info' => false, + 'warnings' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -99,6 +113,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -177,39 +235,57 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['templates'] = $data['templates'] ?? null; - $this->container['list_info'] = $data['list_info'] ?? null; - $this->container['warnings'] = $data['warnings'] ?? null; + $this->setIfExists('templates', $data ?? [], null); + $this->setIfExists('list_info', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateListResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateListResponse { - /** @var TemplateListResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateListResponse */ + return ObjectSerializer::deserialize( $data, TemplateListResponse::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -219,9 +295,7 @@ public static function init(array $data): TemplateListResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -254,6 +328,9 @@ public function getTemplates() */ public function setTemplates(?array $templates) { + if (is_null($templates)) { + throw new InvalidArgumentException('non-nullable templates cannot be null'); + } $this->container['templates'] = $templates; return $this; @@ -278,6 +355,9 @@ public function getListInfo() */ public function setListInfo(?ListInfoResponse $list_info) { + if (is_null($list_info)) { + throw new InvalidArgumentException('non-nullable list_info cannot be null'); + } $this->container['list_info'] = $list_info; return $this; @@ -302,6 +382,9 @@ public function getWarnings() */ public function setWarnings(?array $warnings) { + if (is_null($warnings)) { + throw new InvalidArgumentException('non-nullable warnings cannot be null'); + } $this->container['warnings'] = $warnings; return $this; @@ -310,12 +393,10 @@ public function setWarnings(?array $warnings) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -323,7 +404,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -336,13 +417,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -354,12 +433,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -368,8 +445,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateRemoveUserRequest.php b/sdks/php/src/Model/TemplateRemoveUserRequest.php index 417af15ef..d7a8582f9 100644 --- a/sdks/php/src/Model/TemplateRemoveUserRequest.php +++ b/sdks/php/src/Model/TemplateRemoveUserRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * TemplateRemoveUserRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TemplateRemoveUserRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -76,6 +73,23 @@ class TemplateRemoveUserRequest implements ModelInterface, ArrayAccess, JsonSeri 'email_address' => 'email', ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'account_id' => false, + 'email_address' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -96,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -171,38 +229,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['account_id'] = $data['account_id'] ?? null; - $this->container['email_address'] = $data['email_address'] ?? null; + $this->setIfExists('account_id', $data ?? [], null); + $this->setIfExists('email_address', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateRemoveUserRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateRemoveUserRequest { - /** @var TemplateRemoveUserRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateRemoveUserRequest */ + return ObjectSerializer::deserialize( $data, TemplateRemoveUserRequest::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -212,9 +288,7 @@ public static function init(array $data): TemplateRemoveUserRequest */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -247,6 +321,9 @@ public function getAccountId() */ public function setAccountId(?string $account_id) { + if (is_null($account_id)) { + throw new InvalidArgumentException('non-nullable account_id cannot be null'); + } $this->container['account_id'] = $account_id; return $this; @@ -271,6 +348,9 @@ public function getEmailAddress() */ public function setEmailAddress(?string $email_address) { + if (is_null($email_address)) { + throw new InvalidArgumentException('non-nullable email_address cannot be null'); + } $this->container['email_address'] = $email_address; return $this; @@ -279,12 +359,10 @@ public function setEmailAddress(?string $email_address) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -292,7 +370,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -305,13 +383,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -323,12 +399,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -337,8 +411,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponse.php b/sdks/php/src/Model/TemplateResponse.php index 3501301b1..4041f1856 100644 --- a/sdks/php/src/Model/TemplateResponse.php +++ b/sdks/php/src/Model/TemplateResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,12 +38,8 @@ * * @category Class * @description Contains information about the templates you and your team have created. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class TemplateResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -104,6 +100,36 @@ class TemplateResponse implements ModelInterface, ArrayAccess, JsonSerializable 'accounts' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'template_id' => false, + 'title' => false, + 'message' => false, + 'updated_at' => false, + 'is_embedded' => true, + 'is_creator' => true, + 'can_edit' => true, + 'is_locked' => true, + 'metadata' => false, + 'signer_roles' => false, + 'cc_roles' => false, + 'documents' => false, + 'custom_fields' => true, + 'named_form_fields' => true, + 'accounts' => true, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -124,6 +150,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -238,51 +308,69 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['template_id'] = $data['template_id'] ?? null; - $this->container['title'] = $data['title'] ?? null; - $this->container['message'] = $data['message'] ?? null; - $this->container['updated_at'] = $data['updated_at'] ?? null; - $this->container['is_embedded'] = $data['is_embedded'] ?? null; - $this->container['is_creator'] = $data['is_creator'] ?? null; - $this->container['can_edit'] = $data['can_edit'] ?? null; - $this->container['is_locked'] = $data['is_locked'] ?? null; - $this->container['metadata'] = $data['metadata'] ?? null; - $this->container['signer_roles'] = $data['signer_roles'] ?? null; - $this->container['cc_roles'] = $data['cc_roles'] ?? null; - $this->container['documents'] = $data['documents'] ?? null; - $this->container['custom_fields'] = $data['custom_fields'] ?? null; - $this->container['named_form_fields'] = $data['named_form_fields'] ?? null; - $this->container['accounts'] = $data['accounts'] ?? null; - } - - /** @deprecated use ::init() */ + $this->setIfExists('template_id', $data ?? [], null); + $this->setIfExists('title', $data ?? [], null); + $this->setIfExists('message', $data ?? [], null); + $this->setIfExists('updated_at', $data ?? [], null); + $this->setIfExists('is_embedded', $data ?? [], null); + $this->setIfExists('is_creator', $data ?? [], null); + $this->setIfExists('can_edit', $data ?? [], null); + $this->setIfExists('is_locked', $data ?? [], null); + $this->setIfExists('metadata', $data ?? [], null); + $this->setIfExists('signer_roles', $data ?? [], null); + $this->setIfExists('cc_roles', $data ?? [], null); + $this->setIfExists('documents', $data ?? [], null); + $this->setIfExists('custom_fields', $data ?? [], null); + $this->setIfExists('named_form_fields', $data ?? [], null); + $this->setIfExists('accounts', $data ?? [], null); + } + + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateResponse { - /** @var TemplateResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateResponse */ + return ObjectSerializer::deserialize( $data, TemplateResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -292,9 +380,7 @@ public static function init(array $data): TemplateResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -327,6 +413,9 @@ public function getTemplateId() */ public function setTemplateId(?string $template_id) { + if (is_null($template_id)) { + throw new InvalidArgumentException('non-nullable template_id cannot be null'); + } $this->container['template_id'] = $template_id; return $this; @@ -351,6 +440,9 @@ public function getTitle() */ public function setTitle(?string $title) { + if (is_null($title)) { + throw new InvalidArgumentException('non-nullable title cannot be null'); + } $this->container['title'] = $title; return $this; @@ -375,6 +467,9 @@ public function getMessage() */ public function setMessage(?string $message) { + if (is_null($message)) { + throw new InvalidArgumentException('non-nullable message cannot be null'); + } $this->container['message'] = $message; return $this; @@ -399,6 +494,9 @@ public function getUpdatedAt() */ public function setUpdatedAt(?int $updated_at) { + if (is_null($updated_at)) { + throw new InvalidArgumentException('non-nullable updated_at cannot be null'); + } $this->container['updated_at'] = $updated_at; return $this; @@ -423,6 +521,16 @@ public function getIsEmbedded() */ public function setIsEmbedded(?bool $is_embedded) { + if (is_null($is_embedded)) { + array_push($this->openAPINullablesSetToNull, 'is_embedded'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('is_embedded', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['is_embedded'] = $is_embedded; return $this; @@ -447,6 +555,16 @@ public function getIsCreator() */ public function setIsCreator(?bool $is_creator) { + if (is_null($is_creator)) { + array_push($this->openAPINullablesSetToNull, 'is_creator'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('is_creator', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['is_creator'] = $is_creator; return $this; @@ -471,6 +589,16 @@ public function getCanEdit() */ public function setCanEdit(?bool $can_edit) { + if (is_null($can_edit)) { + array_push($this->openAPINullablesSetToNull, 'can_edit'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('can_edit', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['can_edit'] = $can_edit; return $this; @@ -495,6 +623,16 @@ public function getIsLocked() */ public function setIsLocked(?bool $is_locked) { + if (is_null($is_locked)) { + array_push($this->openAPINullablesSetToNull, 'is_locked'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('is_locked', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['is_locked'] = $is_locked; return $this; @@ -519,6 +657,9 @@ public function getMetadata() */ public function setMetadata(?array $metadata) { + if (is_null($metadata)) { + throw new InvalidArgumentException('non-nullable metadata cannot be null'); + } $this->container['metadata'] = $metadata; return $this; @@ -543,6 +684,9 @@ public function getSignerRoles() */ public function setSignerRoles(?array $signer_roles) { + if (is_null($signer_roles)) { + throw new InvalidArgumentException('non-nullable signer_roles cannot be null'); + } $this->container['signer_roles'] = $signer_roles; return $this; @@ -567,6 +711,9 @@ public function getCcRoles() */ public function setCcRoles(?array $cc_roles) { + if (is_null($cc_roles)) { + throw new InvalidArgumentException('non-nullable cc_roles cannot be null'); + } $this->container['cc_roles'] = $cc_roles; return $this; @@ -591,6 +738,9 @@ public function getDocuments() */ public function setDocuments(?array $documents) { + if (is_null($documents)) { + throw new InvalidArgumentException('non-nullable documents cannot be null'); + } $this->container['documents'] = $documents; return $this; @@ -617,6 +767,16 @@ public function getCustomFields() */ public function setCustomFields(?array $custom_fields) { + if (is_null($custom_fields)) { + array_push($this->openAPINullablesSetToNull, 'custom_fields'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('custom_fields', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['custom_fields'] = $custom_fields; return $this; @@ -643,6 +803,16 @@ public function getNamedFormFields() */ public function setNamedFormFields(?array $named_form_fields) { + if (is_null($named_form_fields)) { + array_push($this->openAPINullablesSetToNull, 'named_form_fields'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('named_form_fields', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['named_form_fields'] = $named_form_fields; return $this; @@ -667,6 +837,16 @@ public function getAccounts() */ public function setAccounts(?array $accounts) { + if (is_null($accounts)) { + array_push($this->openAPINullablesSetToNull, 'accounts'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('accounts', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['accounts'] = $accounts; return $this; @@ -675,12 +855,10 @@ public function setAccounts(?array $accounts) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -688,7 +866,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -701,13 +879,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -719,12 +895,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -733,8 +907,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseAccount.php b/sdks/php/src/Model/TemplateResponseAccount.php index c20c2ee59..47ddefabe 100644 --- a/sdks/php/src/Model/TemplateResponseAccount.php +++ b/sdks/php/src/Model/TemplateResponseAccount.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * TemplateResponseAccount Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class TemplateResponseAccount implements ModelInterface, ArrayAccess, JsonSerializable { @@ -85,6 +81,27 @@ class TemplateResponseAccount implements ModelInterface, ArrayAccess, JsonSerial 'quotas' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'account_id' => false, + 'email_address' => false, + 'is_locked' => false, + 'is_paid_hs' => false, + 'is_paid_hf' => false, + 'quotas' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -105,6 +122,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -192,42 +253,60 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['account_id'] = $data['account_id'] ?? null; - $this->container['email_address'] = $data['email_address'] ?? null; - $this->container['is_locked'] = $data['is_locked'] ?? null; - $this->container['is_paid_hs'] = $data['is_paid_hs'] ?? null; - $this->container['is_paid_hf'] = $data['is_paid_hf'] ?? null; - $this->container['quotas'] = $data['quotas'] ?? null; + $this->setIfExists('account_id', $data ?? [], null); + $this->setIfExists('email_address', $data ?? [], null); + $this->setIfExists('is_locked', $data ?? [], null); + $this->setIfExists('is_paid_hs', $data ?? [], null); + $this->setIfExists('is_paid_hf', $data ?? [], null); + $this->setIfExists('quotas', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateResponseAccount { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateResponseAccount { - /** @var TemplateResponseAccount $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateResponseAccount */ + return ObjectSerializer::deserialize( $data, TemplateResponseAccount::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -237,9 +316,7 @@ public static function init(array $data): TemplateResponseAccount */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -272,6 +349,9 @@ public function getAccountId() */ public function setAccountId(?string $account_id) { + if (is_null($account_id)) { + throw new InvalidArgumentException('non-nullable account_id cannot be null'); + } $this->container['account_id'] = $account_id; return $this; @@ -296,6 +376,9 @@ public function getEmailAddress() */ public function setEmailAddress(?string $email_address) { + if (is_null($email_address)) { + throw new InvalidArgumentException('non-nullable email_address cannot be null'); + } $this->container['email_address'] = $email_address; return $this; @@ -320,6 +403,9 @@ public function getIsLocked() */ public function setIsLocked(?bool $is_locked) { + if (is_null($is_locked)) { + throw new InvalidArgumentException('non-nullable is_locked cannot be null'); + } $this->container['is_locked'] = $is_locked; return $this; @@ -344,6 +430,9 @@ public function getIsPaidHs() */ public function setIsPaidHs(?bool $is_paid_hs) { + if (is_null($is_paid_hs)) { + throw new InvalidArgumentException('non-nullable is_paid_hs cannot be null'); + } $this->container['is_paid_hs'] = $is_paid_hs; return $this; @@ -368,6 +457,9 @@ public function getIsPaidHf() */ public function setIsPaidHf(?bool $is_paid_hf) { + if (is_null($is_paid_hf)) { + throw new InvalidArgumentException('non-nullable is_paid_hf cannot be null'); + } $this->container['is_paid_hf'] = $is_paid_hf; return $this; @@ -392,6 +484,9 @@ public function getQuotas() */ public function setQuotas(?TemplateResponseAccountQuota $quotas) { + if (is_null($quotas)) { + throw new InvalidArgumentException('non-nullable quotas cannot be null'); + } $this->container['quotas'] = $quotas; return $this; @@ -400,12 +495,10 @@ public function setQuotas(?TemplateResponseAccountQuota $quotas) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -413,7 +506,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -426,13 +519,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -444,12 +535,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -458,8 +547,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseAccountQuota.php b/sdks/php/src/Model/TemplateResponseAccountQuota.php index 85ef3448d..46386d6ec 100644 --- a/sdks/php/src/Model/TemplateResponseAccountQuota.php +++ b/sdks/php/src/Model/TemplateResponseAccountQuota.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,12 +38,8 @@ * * @category Class * @description An array of the designated CC roles that must be specified when sending a SignatureRequest using this Template. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class TemplateResponseAccountQuota implements ModelInterface, ArrayAccess, JsonSerializable { @@ -82,6 +78,25 @@ class TemplateResponseAccountQuota implements ModelInterface, ArrayAccess, JsonS 'sms_verifications_left' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'templates_left' => false, + 'api_signature_requests_left' => false, + 'documents_left' => false, + 'sms_verifications_left' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -102,6 +117,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -183,40 +242,58 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['templates_left'] = $data['templates_left'] ?? null; - $this->container['api_signature_requests_left'] = $data['api_signature_requests_left'] ?? null; - $this->container['documents_left'] = $data['documents_left'] ?? null; - $this->container['sms_verifications_left'] = $data['sms_verifications_left'] ?? null; + $this->setIfExists('templates_left', $data ?? [], null); + $this->setIfExists('api_signature_requests_left', $data ?? [], null); + $this->setIfExists('documents_left', $data ?? [], null); + $this->setIfExists('sms_verifications_left', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateResponseAccountQuota { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateResponseAccountQuota { - /** @var TemplateResponseAccountQuota $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateResponseAccountQuota */ + return ObjectSerializer::deserialize( $data, TemplateResponseAccountQuota::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -226,9 +303,7 @@ public static function init(array $data): TemplateResponseAccountQuota */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -261,6 +336,9 @@ public function getTemplatesLeft() */ public function setTemplatesLeft(?int $templates_left) { + if (is_null($templates_left)) { + throw new InvalidArgumentException('non-nullable templates_left cannot be null'); + } $this->container['templates_left'] = $templates_left; return $this; @@ -285,6 +363,9 @@ public function getApiSignatureRequestsLeft() */ public function setApiSignatureRequestsLeft(?int $api_signature_requests_left) { + if (is_null($api_signature_requests_left)) { + throw new InvalidArgumentException('non-nullable api_signature_requests_left cannot be null'); + } $this->container['api_signature_requests_left'] = $api_signature_requests_left; return $this; @@ -309,6 +390,9 @@ public function getDocumentsLeft() */ public function setDocumentsLeft(?int $documents_left) { + if (is_null($documents_left)) { + throw new InvalidArgumentException('non-nullable documents_left cannot be null'); + } $this->container['documents_left'] = $documents_left; return $this; @@ -333,6 +417,9 @@ public function getSmsVerificationsLeft() */ public function setSmsVerificationsLeft(?int $sms_verifications_left) { + if (is_null($sms_verifications_left)) { + throw new InvalidArgumentException('non-nullable sms_verifications_left cannot be null'); + } $this->container['sms_verifications_left'] = $sms_verifications_left; return $this; @@ -341,12 +428,10 @@ public function setSmsVerificationsLeft(?int $sms_verifications_left) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -354,7 +439,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -367,13 +452,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -385,12 +468,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -399,8 +480,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseCCRole.php b/sdks/php/src/Model/TemplateResponseCCRole.php index 5f37a020e..06ee33219 100644 --- a/sdks/php/src/Model/TemplateResponseCCRole.php +++ b/sdks/php/src/Model/TemplateResponseCCRole.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * TemplateResponseCCRole Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class TemplateResponseCCRole implements ModelInterface, ArrayAccess, JsonSerializable { @@ -75,6 +71,22 @@ class TemplateResponseCCRole implements ModelInterface, ArrayAccess, JsonSeriali 'name' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'name' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -95,6 +107,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -167,37 +223,55 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['name'] = $data['name'] ?? null; + $this->setIfExists('name', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateResponseCCRole { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateResponseCCRole { - /** @var TemplateResponseCCRole $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateResponseCCRole */ + return ObjectSerializer::deserialize( $data, TemplateResponseCCRole::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -207,9 +281,7 @@ public static function init(array $data): TemplateResponseCCRole */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -242,6 +314,9 @@ public function getName() */ public function setName(?string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -250,12 +325,10 @@ public function setName(?string $name) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -263,7 +336,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -276,13 +349,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -294,12 +365,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -308,8 +377,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseDocument.php b/sdks/php/src/Model/TemplateResponseDocument.php index d7a45b36f..5377d4ba9 100644 --- a/sdks/php/src/Model/TemplateResponseDocument.php +++ b/sdks/php/src/Model/TemplateResponseDocument.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * TemplateResponseDocument Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class TemplateResponseDocument implements ModelInterface, ArrayAccess, JsonSerializable { @@ -85,6 +81,27 @@ class TemplateResponseDocument implements ModelInterface, ArrayAccess, JsonSeria 'static_fields' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'name' => false, + 'index' => false, + 'field_groups' => false, + 'form_fields' => false, + 'custom_fields' => false, + 'static_fields' => true, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -105,6 +122,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -192,42 +253,60 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['name'] = $data['name'] ?? null; - $this->container['index'] = $data['index'] ?? null; - $this->container['field_groups'] = $data['field_groups'] ?? null; - $this->container['form_fields'] = $data['form_fields'] ?? null; - $this->container['custom_fields'] = $data['custom_fields'] ?? null; - $this->container['static_fields'] = $data['static_fields'] ?? null; + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('index', $data ?? [], null); + $this->setIfExists('field_groups', $data ?? [], null); + $this->setIfExists('form_fields', $data ?? [], null); + $this->setIfExists('custom_fields', $data ?? [], null); + $this->setIfExists('static_fields', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateResponseDocument { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateResponseDocument { - /** @var TemplateResponseDocument $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateResponseDocument */ + return ObjectSerializer::deserialize( $data, TemplateResponseDocument::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -237,9 +316,7 @@ public static function init(array $data): TemplateResponseDocument */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -272,6 +349,9 @@ public function getName() */ public function setName(?string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -296,6 +376,9 @@ public function getIndex() */ public function setIndex(?int $index) { + if (is_null($index)) { + throw new InvalidArgumentException('non-nullable index cannot be null'); + } $this->container['index'] = $index; return $this; @@ -320,6 +403,9 @@ public function getFieldGroups() */ public function setFieldGroups(?array $field_groups) { + if (is_null($field_groups)) { + throw new InvalidArgumentException('non-nullable field_groups cannot be null'); + } $this->container['field_groups'] = $field_groups; return $this; @@ -344,6 +430,9 @@ public function getFormFields() */ public function setFormFields(?array $form_fields) { + if (is_null($form_fields)) { + throw new InvalidArgumentException('non-nullable form_fields cannot be null'); + } $this->container['form_fields'] = $form_fields; return $this; @@ -368,6 +457,9 @@ public function getCustomFields() */ public function setCustomFields(?array $custom_fields) { + if (is_null($custom_fields)) { + throw new InvalidArgumentException('non-nullable custom_fields cannot be null'); + } $this->container['custom_fields'] = $custom_fields; return $this; @@ -392,6 +484,16 @@ public function getStaticFields() */ public function setStaticFields(?array $static_fields) { + if (is_null($static_fields)) { + array_push($this->openAPINullablesSetToNull, 'static_fields'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('static_fields', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['static_fields'] = $static_fields; return $this; @@ -400,12 +502,10 @@ public function setStaticFields(?array $static_fields) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -413,7 +513,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -426,13 +526,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -444,12 +542,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -458,8 +554,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseDocumentCustomFieldBase.php b/sdks/php/src/Model/TemplateResponseDocumentCustomFieldBase.php index a7637f84c..011502522 100644 --- a/sdks/php/src/Model/TemplateResponseDocumentCustomFieldBase.php +++ b/sdks/php/src/Model/TemplateResponseDocumentCustomFieldBase.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,14 +38,10 @@ * * @category Class * @description An array of Form Field objects containing the name and type of each named field. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ -abstract class TemplateResponseDocumentCustomFieldBase implements ModelInterface, ArrayAccess, JsonSerializable +class TemplateResponseDocumentCustomFieldBase implements ModelInterface, ArrayAccess, JsonSerializable { public const DISCRIMINATOR = 'type'; @@ -94,6 +90,31 @@ abstract class TemplateResponseDocumentCustomFieldBase implements ModelInterface 'group' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'api_id' => false, + 'name' => false, + 'signer' => true, + 'x' => false, + 'y' => false, + 'width' => false, + 'height' => false, + 'required' => false, + 'group' => true, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -114,6 +135,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -213,28 +278,28 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['type'] = $data['type'] ?? null; - $this->container['api_id'] = $data['api_id'] ?? null; - $this->container['name'] = $data['name'] ?? null; - $this->container['signer'] = $data['signer'] ?? null; - $this->container['x'] = $data['x'] ?? null; - $this->container['y'] = $data['y'] ?? null; - $this->container['width'] = $data['width'] ?? null; - $this->container['height'] = $data['height'] ?? null; - $this->container['required'] = $data['required'] ?? null; - $this->container['group'] = $data['group'] ?? null; + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('api_id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('signer', $data ?? [], null); + $this->setIfExists('x', $data ?? [], null); + $this->setIfExists('y', $data ?? [], null); + $this->setIfExists('width', $data ?? [], null); + $this->setIfExists('height', $data ?? [], null); + $this->setIfExists('required', $data ?? [], null); + $this->setIfExists('group', $data ?? [], null); // Initialize discriminator property with the model name. $this->container['type'] = static::$openAPIModelName; @@ -256,6 +321,22 @@ public static function discriminatorClassName(array $data): ?string return null; } + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + /** * Show all the invalid properties with reasons. * @@ -268,7 +349,6 @@ public function listInvalidProperties() if ($this->container['type'] === null) { $invalidProperties[] = "'type' can't be null"; } - return $invalidProperties; } @@ -302,6 +382,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -326,6 +409,9 @@ public function getApiId() */ public function setApiId(?string $api_id) { + if (is_null($api_id)) { + throw new InvalidArgumentException('non-nullable api_id cannot be null'); + } $this->container['api_id'] = $api_id; return $this; @@ -350,6 +436,9 @@ public function getName() */ public function setName(?string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -374,6 +463,16 @@ public function getSigner() */ public function setSigner(?string $signer) { + if (is_null($signer)) { + array_push($this->openAPINullablesSetToNull, 'signer'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('signer', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['signer'] = $signer; return $this; @@ -398,6 +497,9 @@ public function getX() */ public function setX(?int $x) { + if (is_null($x)) { + throw new InvalidArgumentException('non-nullable x cannot be null'); + } $this->container['x'] = $x; return $this; @@ -422,6 +524,9 @@ public function getY() */ public function setY(?int $y) { + if (is_null($y)) { + throw new InvalidArgumentException('non-nullable y cannot be null'); + } $this->container['y'] = $y; return $this; @@ -446,6 +551,9 @@ public function getWidth() */ public function setWidth(?int $width) { + if (is_null($width)) { + throw new InvalidArgumentException('non-nullable width cannot be null'); + } $this->container['width'] = $width; return $this; @@ -470,6 +578,9 @@ public function getHeight() */ public function setHeight(?int $height) { + if (is_null($height)) { + throw new InvalidArgumentException('non-nullable height cannot be null'); + } $this->container['height'] = $height; return $this; @@ -494,6 +605,9 @@ public function getRequired() */ public function setRequired(?bool $required) { + if (is_null($required)) { + throw new InvalidArgumentException('non-nullable required cannot be null'); + } $this->container['required'] = $required; return $this; @@ -518,6 +632,16 @@ public function getGroup() */ public function setGroup(?string $group) { + if (is_null($group)) { + array_push($this->openAPINullablesSetToNull, 'group'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('group', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['group'] = $group; return $this; @@ -526,12 +650,10 @@ public function setGroup(?string $group) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -539,7 +661,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -552,13 +674,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -570,12 +690,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -584,8 +702,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseDocumentCustomFieldCheckbox.php b/sdks/php/src/Model/TemplateResponseDocumentCustomFieldCheckbox.php index dca0f6bfa..7ec8dc018 100644 --- a/sdks/php/src/Model/TemplateResponseDocumentCustomFieldCheckbox.php +++ b/sdks/php/src/Model/TemplateResponseDocumentCustomFieldCheckbox.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,6 +28,7 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** @@ -36,11 +36,8 @@ * * @category Class * @description This class extends `TemplateResponseDocumentCustomFieldBase` - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TemplateResponseDocumentCustomFieldCheckbox extends TemplateResponseDocumentCustomFieldBase { @@ -73,6 +70,22 @@ class TemplateResponseDocumentCustomFieldCheckbox extends TemplateResponseDocume 'type' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -93,6 +106,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -165,32 +222,50 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'checkbox'; + $this->setIfExists('type', $data ?? [], 'checkbox'); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateResponseDocumentCustomFieldCheckbox { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateResponseDocumentCustomFieldCheckbox { - /** @var TemplateResponseDocumentCustomFieldCheckbox $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateResponseDocumentCustomFieldCheckbox */ + return ObjectSerializer::deserialize( $data, TemplateResponseDocumentCustomFieldCheckbox::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -205,7 +280,6 @@ public function listInvalidProperties() if ($this->container['type'] === null) { $invalidProperties[] = "'type' can't be null"; } - return $invalidProperties; } @@ -239,6 +313,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -247,12 +324,10 @@ public function setType(string $type) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -260,7 +335,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -273,13 +348,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -291,12 +364,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -305,8 +376,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseDocumentCustomFieldText.php b/sdks/php/src/Model/TemplateResponseDocumentCustomFieldText.php index 50a0dd42b..e63a73978 100644 --- a/sdks/php/src/Model/TemplateResponseDocumentCustomFieldText.php +++ b/sdks/php/src/Model/TemplateResponseDocumentCustomFieldText.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,6 +28,7 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** @@ -36,11 +36,8 @@ * * @category Class * @description This class extends `TemplateResponseDocumentCustomFieldBase` - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TemplateResponseDocumentCustomFieldText extends TemplateResponseDocumentCustomFieldBase { @@ -81,6 +78,26 @@ class TemplateResponseDocumentCustomFieldText extends TemplateResponseDocumentCu 'font_family' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'avg_text_length' => false, + 'is_multiline' => false, + 'original_font_size' => false, + 'font_family' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -101,6 +118,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -185,36 +246,54 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'text'; - $this->container['avg_text_length'] = $data['avg_text_length'] ?? null; - $this->container['is_multiline'] = $data['is_multiline'] ?? null; - $this->container['original_font_size'] = $data['original_font_size'] ?? null; - $this->container['font_family'] = $data['font_family'] ?? null; + $this->setIfExists('type', $data ?? [], 'text'); + $this->setIfExists('avg_text_length', $data ?? [], null); + $this->setIfExists('is_multiline', $data ?? [], null); + $this->setIfExists('original_font_size', $data ?? [], null); + $this->setIfExists('font_family', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateResponseDocumentCustomFieldText { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateResponseDocumentCustomFieldText { - /** @var TemplateResponseDocumentCustomFieldText $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateResponseDocumentCustomFieldText */ + return ObjectSerializer::deserialize( $data, TemplateResponseDocumentCustomFieldText::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -229,7 +308,6 @@ public function listInvalidProperties() if ($this->container['type'] === null) { $invalidProperties[] = "'type' can't be null"; } - return $invalidProperties; } @@ -263,6 +341,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -287,6 +368,9 @@ public function getAvgTextLength() */ public function setAvgTextLength(?TemplateResponseFieldAvgTextLength $avg_text_length) { + if (is_null($avg_text_length)) { + throw new InvalidArgumentException('non-nullable avg_text_length cannot be null'); + } $this->container['avg_text_length'] = $avg_text_length; return $this; @@ -311,6 +395,9 @@ public function getIsMultiline() */ public function setIsMultiline(?bool $is_multiline) { + if (is_null($is_multiline)) { + throw new InvalidArgumentException('non-nullable is_multiline cannot be null'); + } $this->container['is_multiline'] = $is_multiline; return $this; @@ -335,6 +422,9 @@ public function getOriginalFontSize() */ public function setOriginalFontSize(?int $original_font_size) { + if (is_null($original_font_size)) { + throw new InvalidArgumentException('non-nullable original_font_size cannot be null'); + } $this->container['original_font_size'] = $original_font_size; return $this; @@ -359,6 +449,9 @@ public function getFontFamily() */ public function setFontFamily(?string $font_family) { + if (is_null($font_family)) { + throw new InvalidArgumentException('non-nullable font_family cannot be null'); + } $this->container['font_family'] = $font_family; return $this; @@ -367,12 +460,10 @@ public function setFontFamily(?string $font_family) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -380,7 +471,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -393,13 +484,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -411,12 +500,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -425,8 +512,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseDocumentFieldGroup.php b/sdks/php/src/Model/TemplateResponseDocumentFieldGroup.php index 6f8b57907..541714841 100644 --- a/sdks/php/src/Model/TemplateResponseDocumentFieldGroup.php +++ b/sdks/php/src/Model/TemplateResponseDocumentFieldGroup.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * TemplateResponseDocumentFieldGroup Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class TemplateResponseDocumentFieldGroup implements ModelInterface, ArrayAccess, JsonSerializable { @@ -77,6 +73,23 @@ class TemplateResponseDocumentFieldGroup implements ModelInterface, ArrayAccess, 'rule' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'name' => false, + 'rule' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -97,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -172,38 +229,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['name'] = $data['name'] ?? null; - $this->container['rule'] = $data['rule'] ?? null; + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('rule', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateResponseDocumentFieldGroup { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateResponseDocumentFieldGroup { - /** @var TemplateResponseDocumentFieldGroup $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateResponseDocumentFieldGroup */ + return ObjectSerializer::deserialize( $data, TemplateResponseDocumentFieldGroup::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -213,9 +288,7 @@ public static function init(array $data): TemplateResponseDocumentFieldGroup */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -248,6 +321,9 @@ public function getName() */ public function setName(?string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -272,6 +348,9 @@ public function getRule() */ public function setRule(?TemplateResponseDocumentFieldGroupRule $rule) { + if (is_null($rule)) { + throw new InvalidArgumentException('non-nullable rule cannot be null'); + } $this->container['rule'] = $rule; return $this; @@ -280,12 +359,10 @@ public function setRule(?TemplateResponseDocumentFieldGroupRule $rule) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -293,7 +370,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -306,13 +383,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -324,12 +399,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -338,8 +411,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseDocumentFieldGroupRule.php b/sdks/php/src/Model/TemplateResponseDocumentFieldGroupRule.php index 953fd6561..1bd31bde9 100644 --- a/sdks/php/src/Model/TemplateResponseDocumentFieldGroupRule.php +++ b/sdks/php/src/Model/TemplateResponseDocumentFieldGroupRule.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,12 +38,8 @@ * * @category Class * @description The rule used to validate checkboxes in the form field group. See [checkbox field grouping](/api/reference/constants/#checkbox-field-grouping). - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class TemplateResponseDocumentFieldGroupRule implements ModelInterface, ArrayAccess, JsonSerializable { @@ -78,6 +74,23 @@ class TemplateResponseDocumentFieldGroupRule implements ModelInterface, ArrayAcc 'group_label' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'requirement' => false, + 'group_label' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -98,6 +111,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -173,38 +230,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['requirement'] = $data['requirement'] ?? null; - $this->container['group_label'] = $data['group_label'] ?? null; + $this->setIfExists('requirement', $data ?? [], null); + $this->setIfExists('group_label', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateResponseDocumentFieldGroupRule { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateResponseDocumentFieldGroupRule { - /** @var TemplateResponseDocumentFieldGroupRule $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateResponseDocumentFieldGroupRule */ + return ObjectSerializer::deserialize( $data, TemplateResponseDocumentFieldGroupRule::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -214,9 +289,7 @@ public static function init(array $data): TemplateResponseDocumentFieldGroupRule */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -249,6 +322,9 @@ public function getRequirement() */ public function setRequirement(?string $requirement) { + if (is_null($requirement)) { + throw new InvalidArgumentException('non-nullable requirement cannot be null'); + } $this->container['requirement'] = $requirement; return $this; @@ -273,6 +349,9 @@ public function getGroupLabel() */ public function setGroupLabel(?string $group_label) { + if (is_null($group_label)) { + throw new InvalidArgumentException('non-nullable group_label cannot be null'); + } $this->container['group_label'] = $group_label; return $this; @@ -281,12 +360,10 @@ public function setGroupLabel(?string $group_label) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -294,7 +371,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -307,13 +384,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -325,12 +400,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -339,8 +412,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseDocumentFormFieldBase.php b/sdks/php/src/Model/TemplateResponseDocumentFormFieldBase.php index 9d9cfae4e..33cc52c58 100644 --- a/sdks/php/src/Model/TemplateResponseDocumentFormFieldBase.php +++ b/sdks/php/src/Model/TemplateResponseDocumentFormFieldBase.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,14 +38,10 @@ * * @category Class * @description An array of Form Field objects containing the name and type of each named field. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ -abstract class TemplateResponseDocumentFormFieldBase implements ModelInterface, ArrayAccess, JsonSerializable +class TemplateResponseDocumentFormFieldBase implements ModelInterface, ArrayAccess, JsonSerializable { public const DISCRIMINATOR = 'type'; @@ -94,6 +90,31 @@ abstract class TemplateResponseDocumentFormFieldBase implements ModelInterface, 'group' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'api_id' => false, + 'name' => false, + 'signer' => false, + 'x' => false, + 'y' => false, + 'width' => false, + 'height' => false, + 'required' => false, + 'group' => true, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -114,6 +135,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -213,28 +278,28 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['type'] = $data['type'] ?? null; - $this->container['api_id'] = $data['api_id'] ?? null; - $this->container['name'] = $data['name'] ?? null; - $this->container['signer'] = $data['signer'] ?? null; - $this->container['x'] = $data['x'] ?? null; - $this->container['y'] = $data['y'] ?? null; - $this->container['width'] = $data['width'] ?? null; - $this->container['height'] = $data['height'] ?? null; - $this->container['required'] = $data['required'] ?? null; - $this->container['group'] = $data['group'] ?? null; + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('api_id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('signer', $data ?? [], null); + $this->setIfExists('x', $data ?? [], null); + $this->setIfExists('y', $data ?? [], null); + $this->setIfExists('width', $data ?? [], null); + $this->setIfExists('height', $data ?? [], null); + $this->setIfExists('required', $data ?? [], null); + $this->setIfExists('group', $data ?? [], null); // Initialize discriminator property with the model name. $this->container['type'] = static::$openAPIModelName; @@ -274,6 +339,22 @@ public static function discriminatorClassName(array $data): ?string return null; } + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + /** * Show all the invalid properties with reasons. * @@ -286,7 +367,6 @@ public function listInvalidProperties() if ($this->container['type'] === null) { $invalidProperties[] = "'type' can't be null"; } - return $invalidProperties; } @@ -320,6 +400,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -344,6 +427,9 @@ public function getApiId() */ public function setApiId(?string $api_id) { + if (is_null($api_id)) { + throw new InvalidArgumentException('non-nullable api_id cannot be null'); + } $this->container['api_id'] = $api_id; return $this; @@ -368,6 +454,9 @@ public function getName() */ public function setName(?string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -392,6 +481,9 @@ public function getSigner() */ public function setSigner(?string $signer) { + if (is_null($signer)) { + throw new InvalidArgumentException('non-nullable signer cannot be null'); + } $this->container['signer'] = $signer; return $this; @@ -416,6 +508,9 @@ public function getX() */ public function setX(?int $x) { + if (is_null($x)) { + throw new InvalidArgumentException('non-nullable x cannot be null'); + } $this->container['x'] = $x; return $this; @@ -440,6 +535,9 @@ public function getY() */ public function setY(?int $y) { + if (is_null($y)) { + throw new InvalidArgumentException('non-nullable y cannot be null'); + } $this->container['y'] = $y; return $this; @@ -464,6 +562,9 @@ public function getWidth() */ public function setWidth(?int $width) { + if (is_null($width)) { + throw new InvalidArgumentException('non-nullable width cannot be null'); + } $this->container['width'] = $width; return $this; @@ -488,6 +589,9 @@ public function getHeight() */ public function setHeight(?int $height) { + if (is_null($height)) { + throw new InvalidArgumentException('non-nullable height cannot be null'); + } $this->container['height'] = $height; return $this; @@ -512,6 +616,9 @@ public function getRequired() */ public function setRequired(?bool $required) { + if (is_null($required)) { + throw new InvalidArgumentException('non-nullable required cannot be null'); + } $this->container['required'] = $required; return $this; @@ -536,6 +643,16 @@ public function getGroup() */ public function setGroup(?string $group) { + if (is_null($group)) { + array_push($this->openAPINullablesSetToNull, 'group'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('group', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['group'] = $group; return $this; @@ -544,12 +661,10 @@ public function setGroup(?string $group) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -557,7 +672,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -570,13 +685,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -588,12 +701,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -602,8 +713,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseDocumentFormFieldCheckbox.php b/sdks/php/src/Model/TemplateResponseDocumentFormFieldCheckbox.php index 6aafd23cd..bd03254c4 100644 --- a/sdks/php/src/Model/TemplateResponseDocumentFormFieldCheckbox.php +++ b/sdks/php/src/Model/TemplateResponseDocumentFormFieldCheckbox.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,6 +28,7 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** @@ -36,11 +36,8 @@ * * @category Class * @description This class extends `TemplateResponseDocumentFormFieldBase` - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TemplateResponseDocumentFormFieldCheckbox extends TemplateResponseDocumentFormFieldBase { @@ -73,6 +70,22 @@ class TemplateResponseDocumentFormFieldCheckbox extends TemplateResponseDocument 'type' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -93,6 +106,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -165,32 +222,50 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'checkbox'; + $this->setIfExists('type', $data ?? [], 'checkbox'); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateResponseDocumentFormFieldCheckbox { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateResponseDocumentFormFieldCheckbox { - /** @var TemplateResponseDocumentFormFieldCheckbox $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateResponseDocumentFormFieldCheckbox */ + return ObjectSerializer::deserialize( $data, TemplateResponseDocumentFormFieldCheckbox::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -205,7 +280,6 @@ public function listInvalidProperties() if ($this->container['type'] === null) { $invalidProperties[] = "'type' can't be null"; } - return $invalidProperties; } @@ -239,6 +313,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -247,12 +324,10 @@ public function setType(string $type) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -260,7 +335,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -273,13 +348,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -291,12 +364,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -305,8 +376,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseDocumentFormFieldDateSigned.php b/sdks/php/src/Model/TemplateResponseDocumentFormFieldDateSigned.php index 0b8dcf3dd..158d8159c 100644 --- a/sdks/php/src/Model/TemplateResponseDocumentFormFieldDateSigned.php +++ b/sdks/php/src/Model/TemplateResponseDocumentFormFieldDateSigned.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,6 +28,7 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** @@ -36,11 +36,8 @@ * * @category Class * @description This class extends `TemplateResponseDocumentFormFieldBase` - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TemplateResponseDocumentFormFieldDateSigned extends TemplateResponseDocumentFormFieldBase { @@ -73,6 +70,22 @@ class TemplateResponseDocumentFormFieldDateSigned extends TemplateResponseDocume 'type' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -93,6 +106,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -165,32 +222,50 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'date_signed'; + $this->setIfExists('type', $data ?? [], 'date_signed'); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateResponseDocumentFormFieldDateSigned { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateResponseDocumentFormFieldDateSigned { - /** @var TemplateResponseDocumentFormFieldDateSigned $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateResponseDocumentFormFieldDateSigned */ + return ObjectSerializer::deserialize( $data, TemplateResponseDocumentFormFieldDateSigned::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -205,7 +280,6 @@ public function listInvalidProperties() if ($this->container['type'] === null) { $invalidProperties[] = "'type' can't be null"; } - return $invalidProperties; } @@ -239,6 +313,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -247,12 +324,10 @@ public function setType(string $type) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -260,7 +335,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -273,13 +348,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -291,12 +364,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -305,8 +376,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseDocumentFormFieldDropdown.php b/sdks/php/src/Model/TemplateResponseDocumentFormFieldDropdown.php index f43e89b0b..057b5d84d 100644 --- a/sdks/php/src/Model/TemplateResponseDocumentFormFieldDropdown.php +++ b/sdks/php/src/Model/TemplateResponseDocumentFormFieldDropdown.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,6 +28,7 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** @@ -36,11 +36,8 @@ * * @category Class * @description This class extends `TemplateResponseDocumentFormFieldBase` - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TemplateResponseDocumentFormFieldDropdown extends TemplateResponseDocumentFormFieldBase { @@ -73,6 +70,22 @@ class TemplateResponseDocumentFormFieldDropdown extends TemplateResponseDocument 'type' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -93,6 +106,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -165,32 +222,50 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'dropdown'; + $this->setIfExists('type', $data ?? [], 'dropdown'); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateResponseDocumentFormFieldDropdown { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateResponseDocumentFormFieldDropdown { - /** @var TemplateResponseDocumentFormFieldDropdown $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateResponseDocumentFormFieldDropdown */ + return ObjectSerializer::deserialize( $data, TemplateResponseDocumentFormFieldDropdown::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -205,7 +280,6 @@ public function listInvalidProperties() if ($this->container['type'] === null) { $invalidProperties[] = "'type' can't be null"; } - return $invalidProperties; } @@ -239,6 +313,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -247,12 +324,10 @@ public function setType(string $type) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -260,7 +335,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -273,13 +348,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -291,12 +364,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -305,8 +376,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseDocumentFormFieldHyperlink.php b/sdks/php/src/Model/TemplateResponseDocumentFormFieldHyperlink.php index eb4b4fb88..81ffda0ce 100644 --- a/sdks/php/src/Model/TemplateResponseDocumentFormFieldHyperlink.php +++ b/sdks/php/src/Model/TemplateResponseDocumentFormFieldHyperlink.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,6 +28,7 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** @@ -36,11 +36,8 @@ * * @category Class * @description This class extends `TemplateResponseDocumentFormFieldBase` - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TemplateResponseDocumentFormFieldHyperlink extends TemplateResponseDocumentFormFieldBase { @@ -81,6 +78,26 @@ class TemplateResponseDocumentFormFieldHyperlink extends TemplateResponseDocumen 'font_family' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'avg_text_length' => false, + 'is_multiline' => false, + 'original_font_size' => false, + 'font_family' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -101,6 +118,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -185,36 +246,54 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'hyperlink'; - $this->container['avg_text_length'] = $data['avg_text_length'] ?? null; - $this->container['is_multiline'] = $data['is_multiline'] ?? null; - $this->container['original_font_size'] = $data['original_font_size'] ?? null; - $this->container['font_family'] = $data['font_family'] ?? null; + $this->setIfExists('type', $data ?? [], 'hyperlink'); + $this->setIfExists('avg_text_length', $data ?? [], null); + $this->setIfExists('is_multiline', $data ?? [], null); + $this->setIfExists('original_font_size', $data ?? [], null); + $this->setIfExists('font_family', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateResponseDocumentFormFieldHyperlink { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateResponseDocumentFormFieldHyperlink { - /** @var TemplateResponseDocumentFormFieldHyperlink $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateResponseDocumentFormFieldHyperlink */ + return ObjectSerializer::deserialize( $data, TemplateResponseDocumentFormFieldHyperlink::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -229,7 +308,6 @@ public function listInvalidProperties() if ($this->container['type'] === null) { $invalidProperties[] = "'type' can't be null"; } - return $invalidProperties; } @@ -263,6 +341,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -287,6 +368,9 @@ public function getAvgTextLength() */ public function setAvgTextLength(?TemplateResponseFieldAvgTextLength $avg_text_length) { + if (is_null($avg_text_length)) { + throw new InvalidArgumentException('non-nullable avg_text_length cannot be null'); + } $this->container['avg_text_length'] = $avg_text_length; return $this; @@ -311,6 +395,9 @@ public function getIsMultiline() */ public function setIsMultiline(?bool $is_multiline) { + if (is_null($is_multiline)) { + throw new InvalidArgumentException('non-nullable is_multiline cannot be null'); + } $this->container['is_multiline'] = $is_multiline; return $this; @@ -335,6 +422,9 @@ public function getOriginalFontSize() */ public function setOriginalFontSize(?int $original_font_size) { + if (is_null($original_font_size)) { + throw new InvalidArgumentException('non-nullable original_font_size cannot be null'); + } $this->container['original_font_size'] = $original_font_size; return $this; @@ -359,6 +449,9 @@ public function getFontFamily() */ public function setFontFamily(?string $font_family) { + if (is_null($font_family)) { + throw new InvalidArgumentException('non-nullable font_family cannot be null'); + } $this->container['font_family'] = $font_family; return $this; @@ -367,12 +460,10 @@ public function setFontFamily(?string $font_family) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -380,7 +471,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -393,13 +484,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -411,12 +500,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -425,8 +512,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseDocumentFormFieldInitials.php b/sdks/php/src/Model/TemplateResponseDocumentFormFieldInitials.php index 33dee5480..976a27fba 100644 --- a/sdks/php/src/Model/TemplateResponseDocumentFormFieldInitials.php +++ b/sdks/php/src/Model/TemplateResponseDocumentFormFieldInitials.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,6 +28,7 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** @@ -36,11 +36,8 @@ * * @category Class * @description This class extends `TemplateResponseDocumentFormFieldBase` - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TemplateResponseDocumentFormFieldInitials extends TemplateResponseDocumentFormFieldBase { @@ -73,6 +70,22 @@ class TemplateResponseDocumentFormFieldInitials extends TemplateResponseDocument 'type' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -93,6 +106,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -165,32 +222,50 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'initials'; + $this->setIfExists('type', $data ?? [], 'initials'); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateResponseDocumentFormFieldInitials { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateResponseDocumentFormFieldInitials { - /** @var TemplateResponseDocumentFormFieldInitials $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateResponseDocumentFormFieldInitials */ + return ObjectSerializer::deserialize( $data, TemplateResponseDocumentFormFieldInitials::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -205,7 +280,6 @@ public function listInvalidProperties() if ($this->container['type'] === null) { $invalidProperties[] = "'type' can't be null"; } - return $invalidProperties; } @@ -239,6 +313,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -247,12 +324,10 @@ public function setType(string $type) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -260,7 +335,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -273,13 +348,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -291,12 +364,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -305,8 +376,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseDocumentFormFieldRadio.php b/sdks/php/src/Model/TemplateResponseDocumentFormFieldRadio.php index de530b588..bd0d28e85 100644 --- a/sdks/php/src/Model/TemplateResponseDocumentFormFieldRadio.php +++ b/sdks/php/src/Model/TemplateResponseDocumentFormFieldRadio.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,6 +28,7 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** @@ -36,11 +36,8 @@ * * @category Class * @description This class extends `TemplateResponseDocumentFormFieldBase` - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TemplateResponseDocumentFormFieldRadio extends TemplateResponseDocumentFormFieldBase { @@ -73,6 +70,22 @@ class TemplateResponseDocumentFormFieldRadio extends TemplateResponseDocumentFor 'type' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -93,6 +106,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -165,32 +222,50 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'radio'; + $this->setIfExists('type', $data ?? [], 'radio'); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateResponseDocumentFormFieldRadio { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateResponseDocumentFormFieldRadio { - /** @var TemplateResponseDocumentFormFieldRadio $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateResponseDocumentFormFieldRadio */ + return ObjectSerializer::deserialize( $data, TemplateResponseDocumentFormFieldRadio::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -205,7 +280,6 @@ public function listInvalidProperties() if ($this->container['type'] === null) { $invalidProperties[] = "'type' can't be null"; } - return $invalidProperties; } @@ -239,6 +313,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -247,12 +324,10 @@ public function setType(string $type) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -260,7 +335,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -273,13 +348,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -291,12 +364,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -305,8 +376,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseDocumentFormFieldSignature.php b/sdks/php/src/Model/TemplateResponseDocumentFormFieldSignature.php index 7a2951213..9effb72b7 100644 --- a/sdks/php/src/Model/TemplateResponseDocumentFormFieldSignature.php +++ b/sdks/php/src/Model/TemplateResponseDocumentFormFieldSignature.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,6 +28,7 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** @@ -36,11 +36,8 @@ * * @category Class * @description This class extends `TemplateResponseDocumentFormFieldBase` - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TemplateResponseDocumentFormFieldSignature extends TemplateResponseDocumentFormFieldBase { @@ -73,6 +70,22 @@ class TemplateResponseDocumentFormFieldSignature extends TemplateResponseDocumen 'type' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -93,6 +106,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -165,32 +222,50 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'signature'; + $this->setIfExists('type', $data ?? [], 'signature'); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateResponseDocumentFormFieldSignature { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateResponseDocumentFormFieldSignature { - /** @var TemplateResponseDocumentFormFieldSignature $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateResponseDocumentFormFieldSignature */ + return ObjectSerializer::deserialize( $data, TemplateResponseDocumentFormFieldSignature::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -205,7 +280,6 @@ public function listInvalidProperties() if ($this->container['type'] === null) { $invalidProperties[] = "'type' can't be null"; } - return $invalidProperties; } @@ -239,6 +313,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -247,12 +324,10 @@ public function setType(string $type) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -260,7 +335,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -273,13 +348,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -291,12 +364,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -305,8 +376,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseDocumentFormFieldText.php b/sdks/php/src/Model/TemplateResponseDocumentFormFieldText.php index a7fa915a2..0684e1d67 100644 --- a/sdks/php/src/Model/TemplateResponseDocumentFormFieldText.php +++ b/sdks/php/src/Model/TemplateResponseDocumentFormFieldText.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -37,11 +36,8 @@ * * @category Class * @description This class extends `TemplateResponseDocumentFormFieldBase` - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TemplateResponseDocumentFormFieldText extends TemplateResponseDocumentFormFieldBase { @@ -84,6 +80,27 @@ class TemplateResponseDocumentFormFieldText extends TemplateResponseDocumentForm 'validation_type' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'avg_text_length' => false, + 'is_multiline' => false, + 'original_font_size' => false, + 'font_family' => false, + 'validation_type' => true, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -104,6 +121,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -223,37 +284,55 @@ public function getValidationTypeAllowableValues() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'text'; - $this->container['avg_text_length'] = $data['avg_text_length'] ?? null; - $this->container['is_multiline'] = $data['is_multiline'] ?? null; - $this->container['original_font_size'] = $data['original_font_size'] ?? null; - $this->container['font_family'] = $data['font_family'] ?? null; - $this->container['validation_type'] = $data['validation_type'] ?? null; + $this->setIfExists('type', $data ?? [], 'text'); + $this->setIfExists('avg_text_length', $data ?? [], null); + $this->setIfExists('is_multiline', $data ?? [], null); + $this->setIfExists('original_font_size', $data ?? [], null); + $this->setIfExists('font_family', $data ?? [], null); + $this->setIfExists('validation_type', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateResponseDocumentFormFieldText { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateResponseDocumentFormFieldText { - /** @var TemplateResponseDocumentFormFieldText $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateResponseDocumentFormFieldText */ + return ObjectSerializer::deserialize( $data, TemplateResponseDocumentFormFieldText::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -310,6 +389,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -334,6 +416,9 @@ public function getAvgTextLength() */ public function setAvgTextLength(?TemplateResponseFieldAvgTextLength $avg_text_length) { + if (is_null($avg_text_length)) { + throw new InvalidArgumentException('non-nullable avg_text_length cannot be null'); + } $this->container['avg_text_length'] = $avg_text_length; return $this; @@ -358,6 +443,9 @@ public function getIsMultiline() */ public function setIsMultiline(?bool $is_multiline) { + if (is_null($is_multiline)) { + throw new InvalidArgumentException('non-nullable is_multiline cannot be null'); + } $this->container['is_multiline'] = $is_multiline; return $this; @@ -382,6 +470,9 @@ public function getOriginalFontSize() */ public function setOriginalFontSize(?int $original_font_size) { + if (is_null($original_font_size)) { + throw new InvalidArgumentException('non-nullable original_font_size cannot be null'); + } $this->container['original_font_size'] = $original_font_size; return $this; @@ -406,6 +497,9 @@ public function getFontFamily() */ public function setFontFamily(?string $font_family) { + if (is_null($font_family)) { + throw new InvalidArgumentException('non-nullable font_family cannot be null'); + } $this->container['font_family'] = $font_family; return $this; @@ -430,6 +524,16 @@ public function getValidationType() */ public function setValidationType(?string $validation_type) { + if (is_null($validation_type)) { + array_push($this->openAPINullablesSetToNull, 'validation_type'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('validation_type', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $allowedValues = $this->getValidationTypeAllowableValues(); if (!is_null($validation_type) && !in_array($validation_type, $allowedValues, true)) { throw new InvalidArgumentException( @@ -448,12 +552,10 @@ public function setValidationType(?string $validation_type) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -461,7 +563,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -474,13 +576,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -492,12 +592,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -506,8 +604,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseDocumentStaticFieldBase.php b/sdks/php/src/Model/TemplateResponseDocumentStaticFieldBase.php index 5e52961af..bd18e1847 100644 --- a/sdks/php/src/Model/TemplateResponseDocumentStaticFieldBase.php +++ b/sdks/php/src/Model/TemplateResponseDocumentStaticFieldBase.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,14 +38,10 @@ * * @category Class * @description An array describing static overlay fields. **NOTE:** Only available for certain subscriptions. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ -abstract class TemplateResponseDocumentStaticFieldBase implements ModelInterface, ArrayAccess, JsonSerializable +class TemplateResponseDocumentStaticFieldBase implements ModelInterface, ArrayAccess, JsonSerializable { public const DISCRIMINATOR = 'type'; @@ -94,6 +90,31 @@ abstract class TemplateResponseDocumentStaticFieldBase implements ModelInterface 'group' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'api_id' => false, + 'name' => false, + 'signer' => false, + 'x' => false, + 'y' => false, + 'width' => false, + 'height' => false, + 'required' => false, + 'group' => true, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -114,6 +135,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -213,28 +278,28 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['type'] = $data['type'] ?? null; - $this->container['api_id'] = $data['api_id'] ?? null; - $this->container['name'] = $data['name'] ?? null; - $this->container['signer'] = $data['signer'] ?? 'me_now'; - $this->container['x'] = $data['x'] ?? null; - $this->container['y'] = $data['y'] ?? null; - $this->container['width'] = $data['width'] ?? null; - $this->container['height'] = $data['height'] ?? null; - $this->container['required'] = $data['required'] ?? null; - $this->container['group'] = $data['group'] ?? null; + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('api_id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('signer', $data ?? [], 'me_now'); + $this->setIfExists('x', $data ?? [], null); + $this->setIfExists('y', $data ?? [], null); + $this->setIfExists('width', $data ?? [], null); + $this->setIfExists('height', $data ?? [], null); + $this->setIfExists('required', $data ?? [], null); + $this->setIfExists('group', $data ?? [], null); // Initialize discriminator property with the model name. $this->container['type'] = static::$openAPIModelName; @@ -274,6 +339,22 @@ public static function discriminatorClassName(array $data): ?string return null; } + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + /** * Show all the invalid properties with reasons. * @@ -286,7 +367,6 @@ public function listInvalidProperties() if ($this->container['type'] === null) { $invalidProperties[] = "'type' can't be null"; } - return $invalidProperties; } @@ -320,6 +400,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -344,6 +427,9 @@ public function getApiId() */ public function setApiId(?string $api_id) { + if (is_null($api_id)) { + throw new InvalidArgumentException('non-nullable api_id cannot be null'); + } $this->container['api_id'] = $api_id; return $this; @@ -368,6 +454,9 @@ public function getName() */ public function setName(?string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -392,6 +481,9 @@ public function getSigner() */ public function setSigner(?string $signer) { + if (is_null($signer)) { + throw new InvalidArgumentException('non-nullable signer cannot be null'); + } $this->container['signer'] = $signer; return $this; @@ -416,6 +508,9 @@ public function getX() */ public function setX(?int $x) { + if (is_null($x)) { + throw new InvalidArgumentException('non-nullable x cannot be null'); + } $this->container['x'] = $x; return $this; @@ -440,6 +535,9 @@ public function getY() */ public function setY(?int $y) { + if (is_null($y)) { + throw new InvalidArgumentException('non-nullable y cannot be null'); + } $this->container['y'] = $y; return $this; @@ -464,6 +562,9 @@ public function getWidth() */ public function setWidth(?int $width) { + if (is_null($width)) { + throw new InvalidArgumentException('non-nullable width cannot be null'); + } $this->container['width'] = $width; return $this; @@ -488,6 +589,9 @@ public function getHeight() */ public function setHeight(?int $height) { + if (is_null($height)) { + throw new InvalidArgumentException('non-nullable height cannot be null'); + } $this->container['height'] = $height; return $this; @@ -512,6 +616,9 @@ public function getRequired() */ public function setRequired(?bool $required) { + if (is_null($required)) { + throw new InvalidArgumentException('non-nullable required cannot be null'); + } $this->container['required'] = $required; return $this; @@ -536,6 +643,16 @@ public function getGroup() */ public function setGroup(?string $group) { + if (is_null($group)) { + array_push($this->openAPINullablesSetToNull, 'group'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('group', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['group'] = $group; return $this; @@ -544,12 +661,10 @@ public function setGroup(?string $group) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -557,7 +672,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -570,13 +685,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -588,12 +701,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -602,8 +713,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseDocumentStaticFieldCheckbox.php b/sdks/php/src/Model/TemplateResponseDocumentStaticFieldCheckbox.php index 06bc51ede..9739d2e05 100644 --- a/sdks/php/src/Model/TemplateResponseDocumentStaticFieldCheckbox.php +++ b/sdks/php/src/Model/TemplateResponseDocumentStaticFieldCheckbox.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,6 +28,7 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** @@ -36,11 +36,8 @@ * * @category Class * @description This class extends `TemplateResponseDocumentStaticFieldBase` - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TemplateResponseDocumentStaticFieldCheckbox extends TemplateResponseDocumentStaticFieldBase { @@ -73,6 +70,22 @@ class TemplateResponseDocumentStaticFieldCheckbox extends TemplateResponseDocume 'type' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -93,6 +106,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -165,32 +222,50 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'checkbox'; + $this->setIfExists('type', $data ?? [], 'checkbox'); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateResponseDocumentStaticFieldCheckbox { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateResponseDocumentStaticFieldCheckbox { - /** @var TemplateResponseDocumentStaticFieldCheckbox $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateResponseDocumentStaticFieldCheckbox */ + return ObjectSerializer::deserialize( $data, TemplateResponseDocumentStaticFieldCheckbox::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -205,7 +280,6 @@ public function listInvalidProperties() if ($this->container['type'] === null) { $invalidProperties[] = "'type' can't be null"; } - return $invalidProperties; } @@ -239,6 +313,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -247,12 +324,10 @@ public function setType(string $type) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -260,7 +335,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -273,13 +348,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -291,12 +364,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -305,8 +376,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseDocumentStaticFieldDateSigned.php b/sdks/php/src/Model/TemplateResponseDocumentStaticFieldDateSigned.php index 42c79cd09..911febf8d 100644 --- a/sdks/php/src/Model/TemplateResponseDocumentStaticFieldDateSigned.php +++ b/sdks/php/src/Model/TemplateResponseDocumentStaticFieldDateSigned.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,6 +28,7 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** @@ -36,11 +36,8 @@ * * @category Class * @description This class extends `TemplateResponseDocumentStaticFieldBase` - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TemplateResponseDocumentStaticFieldDateSigned extends TemplateResponseDocumentStaticFieldBase { @@ -73,6 +70,22 @@ class TemplateResponseDocumentStaticFieldDateSigned extends TemplateResponseDocu 'type' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -93,6 +106,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -165,32 +222,50 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'date_signed'; + $this->setIfExists('type', $data ?? [], 'date_signed'); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateResponseDocumentStaticFieldDateSigned { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateResponseDocumentStaticFieldDateSigned { - /** @var TemplateResponseDocumentStaticFieldDateSigned $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateResponseDocumentStaticFieldDateSigned */ + return ObjectSerializer::deserialize( $data, TemplateResponseDocumentStaticFieldDateSigned::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -205,7 +280,6 @@ public function listInvalidProperties() if ($this->container['type'] === null) { $invalidProperties[] = "'type' can't be null"; } - return $invalidProperties; } @@ -239,6 +313,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -247,12 +324,10 @@ public function setType(string $type) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -260,7 +335,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -273,13 +348,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -291,12 +364,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -305,8 +376,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseDocumentStaticFieldDropdown.php b/sdks/php/src/Model/TemplateResponseDocumentStaticFieldDropdown.php index 299898fbf..6022f9289 100644 --- a/sdks/php/src/Model/TemplateResponseDocumentStaticFieldDropdown.php +++ b/sdks/php/src/Model/TemplateResponseDocumentStaticFieldDropdown.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,6 +28,7 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** @@ -36,11 +36,8 @@ * * @category Class * @description This class extends `TemplateResponseDocumentStaticFieldBase` - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TemplateResponseDocumentStaticFieldDropdown extends TemplateResponseDocumentStaticFieldBase { @@ -73,6 +70,22 @@ class TemplateResponseDocumentStaticFieldDropdown extends TemplateResponseDocume 'type' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -93,6 +106,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -165,32 +222,50 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'dropdown'; + $this->setIfExists('type', $data ?? [], 'dropdown'); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateResponseDocumentStaticFieldDropdown { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateResponseDocumentStaticFieldDropdown { - /** @var TemplateResponseDocumentStaticFieldDropdown $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateResponseDocumentStaticFieldDropdown */ + return ObjectSerializer::deserialize( $data, TemplateResponseDocumentStaticFieldDropdown::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -205,7 +280,6 @@ public function listInvalidProperties() if ($this->container['type'] === null) { $invalidProperties[] = "'type' can't be null"; } - return $invalidProperties; } @@ -239,6 +313,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -247,12 +324,10 @@ public function setType(string $type) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -260,7 +335,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -273,13 +348,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -291,12 +364,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -305,8 +376,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseDocumentStaticFieldHyperlink.php b/sdks/php/src/Model/TemplateResponseDocumentStaticFieldHyperlink.php index 9cb8555af..246bea450 100644 --- a/sdks/php/src/Model/TemplateResponseDocumentStaticFieldHyperlink.php +++ b/sdks/php/src/Model/TemplateResponseDocumentStaticFieldHyperlink.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,6 +28,7 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** @@ -36,11 +36,8 @@ * * @category Class * @description This class extends `TemplateResponseDocumentStaticFieldBase` - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TemplateResponseDocumentStaticFieldHyperlink extends TemplateResponseDocumentStaticFieldBase { @@ -73,6 +70,22 @@ class TemplateResponseDocumentStaticFieldHyperlink extends TemplateResponseDocum 'type' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -93,6 +106,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -165,32 +222,50 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'hyperlink'; + $this->setIfExists('type', $data ?? [], 'hyperlink'); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateResponseDocumentStaticFieldHyperlink { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateResponseDocumentStaticFieldHyperlink { - /** @var TemplateResponseDocumentStaticFieldHyperlink $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateResponseDocumentStaticFieldHyperlink */ + return ObjectSerializer::deserialize( $data, TemplateResponseDocumentStaticFieldHyperlink::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -205,7 +280,6 @@ public function listInvalidProperties() if ($this->container['type'] === null) { $invalidProperties[] = "'type' can't be null"; } - return $invalidProperties; } @@ -239,6 +313,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -247,12 +324,10 @@ public function setType(string $type) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -260,7 +335,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -273,13 +348,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -291,12 +364,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -305,8 +376,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseDocumentStaticFieldInitials.php b/sdks/php/src/Model/TemplateResponseDocumentStaticFieldInitials.php index df100948b..339b3a2a5 100644 --- a/sdks/php/src/Model/TemplateResponseDocumentStaticFieldInitials.php +++ b/sdks/php/src/Model/TemplateResponseDocumentStaticFieldInitials.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,6 +28,7 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** @@ -36,11 +36,8 @@ * * @category Class * @description This class extends `TemplateResponseDocumentStaticFieldBase` - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TemplateResponseDocumentStaticFieldInitials extends TemplateResponseDocumentStaticFieldBase { @@ -73,6 +70,22 @@ class TemplateResponseDocumentStaticFieldInitials extends TemplateResponseDocume 'type' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -93,6 +106,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -165,32 +222,50 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'initials'; + $this->setIfExists('type', $data ?? [], 'initials'); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateResponseDocumentStaticFieldInitials { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateResponseDocumentStaticFieldInitials { - /** @var TemplateResponseDocumentStaticFieldInitials $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateResponseDocumentStaticFieldInitials */ + return ObjectSerializer::deserialize( $data, TemplateResponseDocumentStaticFieldInitials::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -205,7 +280,6 @@ public function listInvalidProperties() if ($this->container['type'] === null) { $invalidProperties[] = "'type' can't be null"; } - return $invalidProperties; } @@ -239,6 +313,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -247,12 +324,10 @@ public function setType(string $type) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -260,7 +335,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -273,13 +348,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -291,12 +364,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -305,8 +376,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseDocumentStaticFieldRadio.php b/sdks/php/src/Model/TemplateResponseDocumentStaticFieldRadio.php index 72dfaf30b..8dc139712 100644 --- a/sdks/php/src/Model/TemplateResponseDocumentStaticFieldRadio.php +++ b/sdks/php/src/Model/TemplateResponseDocumentStaticFieldRadio.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,6 +28,7 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** @@ -36,11 +36,8 @@ * * @category Class * @description This class extends `TemplateResponseDocumentStaticFieldBase` - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TemplateResponseDocumentStaticFieldRadio extends TemplateResponseDocumentStaticFieldBase { @@ -73,6 +70,22 @@ class TemplateResponseDocumentStaticFieldRadio extends TemplateResponseDocumentS 'type' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -93,6 +106,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -165,32 +222,50 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'radio'; + $this->setIfExists('type', $data ?? [], 'radio'); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateResponseDocumentStaticFieldRadio { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateResponseDocumentStaticFieldRadio { - /** @var TemplateResponseDocumentStaticFieldRadio $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateResponseDocumentStaticFieldRadio */ + return ObjectSerializer::deserialize( $data, TemplateResponseDocumentStaticFieldRadio::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -205,7 +280,6 @@ public function listInvalidProperties() if ($this->container['type'] === null) { $invalidProperties[] = "'type' can't be null"; } - return $invalidProperties; } @@ -239,6 +313,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -247,12 +324,10 @@ public function setType(string $type) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -260,7 +335,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -273,13 +348,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -291,12 +364,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -305,8 +376,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseDocumentStaticFieldSignature.php b/sdks/php/src/Model/TemplateResponseDocumentStaticFieldSignature.php index c98ba38ed..c86d1c9a3 100644 --- a/sdks/php/src/Model/TemplateResponseDocumentStaticFieldSignature.php +++ b/sdks/php/src/Model/TemplateResponseDocumentStaticFieldSignature.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,6 +28,7 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** @@ -36,11 +36,8 @@ * * @category Class * @description This class extends `TemplateResponseDocumentStaticFieldBase` - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TemplateResponseDocumentStaticFieldSignature extends TemplateResponseDocumentStaticFieldBase { @@ -73,6 +70,22 @@ class TemplateResponseDocumentStaticFieldSignature extends TemplateResponseDocum 'type' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -93,6 +106,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -165,32 +222,50 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'signature'; + $this->setIfExists('type', $data ?? [], 'signature'); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateResponseDocumentStaticFieldSignature { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateResponseDocumentStaticFieldSignature { - /** @var TemplateResponseDocumentStaticFieldSignature $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateResponseDocumentStaticFieldSignature */ + return ObjectSerializer::deserialize( $data, TemplateResponseDocumentStaticFieldSignature::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -205,7 +280,6 @@ public function listInvalidProperties() if ($this->container['type'] === null) { $invalidProperties[] = "'type' can't be null"; } - return $invalidProperties; } @@ -239,6 +313,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -247,12 +324,10 @@ public function setType(string $type) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -260,7 +335,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -273,13 +348,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -291,12 +364,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -305,8 +376,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseDocumentStaticFieldText.php b/sdks/php/src/Model/TemplateResponseDocumentStaticFieldText.php index 8b2bf3f23..ec89541e3 100644 --- a/sdks/php/src/Model/TemplateResponseDocumentStaticFieldText.php +++ b/sdks/php/src/Model/TemplateResponseDocumentStaticFieldText.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,6 +28,7 @@ namespace Dropbox\Sign\Model; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use ReturnTypeWillChange; /** @@ -36,11 +36,8 @@ * * @category Class * @description This class extends `TemplateResponseDocumentStaticFieldBase` - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TemplateResponseDocumentStaticFieldText extends TemplateResponseDocumentStaticFieldBase { @@ -73,6 +70,22 @@ class TemplateResponseDocumentStaticFieldText extends TemplateResponseDocumentSt 'type' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -93,6 +106,50 @@ public static function openAPIFormats() return self::$openAPIFormats + parent::openAPIFormats(); } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -165,32 +222,50 @@ public function getModelName() /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { parent::__construct($data); - $this->container['type'] = $data['type'] ?? 'text'; + $this->setIfExists('type', $data ?? [], 'text'); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateResponseDocumentStaticFieldText { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateResponseDocumentStaticFieldText { - /** @var TemplateResponseDocumentStaticFieldText $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateResponseDocumentStaticFieldText */ + return ObjectSerializer::deserialize( $data, TemplateResponseDocumentStaticFieldText::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -205,7 +280,6 @@ public function listInvalidProperties() if ($this->container['type'] === null) { $invalidProperties[] = "'type' can't be null"; } - return $invalidProperties; } @@ -239,6 +313,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $this->container['type'] = $type; return $this; @@ -247,12 +324,10 @@ public function setType(string $type) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -260,7 +335,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -273,13 +348,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -291,12 +364,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -305,8 +376,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseFieldAvgTextLength.php b/sdks/php/src/Model/TemplateResponseFieldAvgTextLength.php index 02e025d6b..9277db26a 100644 --- a/sdks/php/src/Model/TemplateResponseFieldAvgTextLength.php +++ b/sdks/php/src/Model/TemplateResponseFieldAvgTextLength.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,12 +38,8 @@ * * @category Class * @description Average text length in this field. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class TemplateResponseFieldAvgTextLength implements ModelInterface, ArrayAccess, JsonSerializable { @@ -78,6 +74,23 @@ class TemplateResponseFieldAvgTextLength implements ModelInterface, ArrayAccess, 'num_chars_per_line' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'num_lines' => false, + 'num_chars_per_line' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -98,6 +111,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -173,38 +230,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['num_lines'] = $data['num_lines'] ?? null; - $this->container['num_chars_per_line'] = $data['num_chars_per_line'] ?? null; + $this->setIfExists('num_lines', $data ?? [], null); + $this->setIfExists('num_chars_per_line', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateResponseFieldAvgTextLength { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateResponseFieldAvgTextLength { - /** @var TemplateResponseFieldAvgTextLength $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateResponseFieldAvgTextLength */ + return ObjectSerializer::deserialize( $data, TemplateResponseFieldAvgTextLength::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -214,9 +289,7 @@ public static function init(array $data): TemplateResponseFieldAvgTextLength */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -249,6 +322,9 @@ public function getNumLines() */ public function setNumLines(?int $num_lines) { + if (is_null($num_lines)) { + throw new InvalidArgumentException('non-nullable num_lines cannot be null'); + } $this->container['num_lines'] = $num_lines; return $this; @@ -273,6 +349,9 @@ public function getNumCharsPerLine() */ public function setNumCharsPerLine(?int $num_chars_per_line) { + if (is_null($num_chars_per_line)) { + throw new InvalidArgumentException('non-nullable num_chars_per_line cannot be null'); + } $this->container['num_chars_per_line'] = $num_chars_per_line; return $this; @@ -281,12 +360,10 @@ public function setNumCharsPerLine(?int $num_chars_per_line) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -294,7 +371,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -307,13 +384,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -325,12 +400,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -339,8 +412,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateResponseSignerRole.php b/sdks/php/src/Model/TemplateResponseSignerRole.php index 1f2e9d9d4..98a80c6e0 100644 --- a/sdks/php/src/Model/TemplateResponseSignerRole.php +++ b/sdks/php/src/Model/TemplateResponseSignerRole.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * TemplateResponseSignerRole Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class TemplateResponseSignerRole implements ModelInterface, ArrayAccess, JsonSerializable { @@ -77,6 +73,23 @@ class TemplateResponseSignerRole implements ModelInterface, ArrayAccess, JsonSer 'order' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'name' => false, + 'order' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -97,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -172,38 +229,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['name'] = $data['name'] ?? null; - $this->container['order'] = $data['order'] ?? null; + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('order', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateResponseSignerRole { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateResponseSignerRole { - /** @var TemplateResponseSignerRole $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateResponseSignerRole */ + return ObjectSerializer::deserialize( $data, TemplateResponseSignerRole::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -213,9 +288,7 @@ public static function init(array $data): TemplateResponseSignerRole */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -248,6 +321,9 @@ public function getName() */ public function setName(?string $name) { + if (is_null($name)) { + throw new InvalidArgumentException('non-nullable name cannot be null'); + } $this->container['name'] = $name; return $this; @@ -272,6 +348,9 @@ public function getOrder() */ public function setOrder(?int $order) { + if (is_null($order)) { + throw new InvalidArgumentException('non-nullable order cannot be null'); + } $this->container['order'] = $order; return $this; @@ -280,12 +359,10 @@ public function setOrder(?int $order) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -293,7 +370,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -306,13 +383,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -324,12 +399,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -338,8 +411,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateUpdateFilesRequest.php b/sdks/php/src/Model/TemplateUpdateFilesRequest.php index 29ec13356..7c165ff7d 100644 --- a/sdks/php/src/Model/TemplateUpdateFilesRequest.php +++ b/sdks/php/src/Model/TemplateUpdateFilesRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -39,11 +38,8 @@ * TemplateUpdateFilesRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class TemplateUpdateFilesRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -86,6 +82,27 @@ class TemplateUpdateFilesRequest implements ModelInterface, ArrayAccess, JsonSer 'test_mode' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'client_id' => false, + 'files' => false, + 'file_urls' => false, + 'message' => false, + 'subject' => false, + 'test_mode' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -106,6 +123,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -193,42 +254,60 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['client_id'] = $data['client_id'] ?? null; - $this->container['files'] = $data['files'] ?? null; - $this->container['file_urls'] = $data['file_urls'] ?? null; - $this->container['message'] = $data['message'] ?? null; - $this->container['subject'] = $data['subject'] ?? null; - $this->container['test_mode'] = $data['test_mode'] ?? false; + $this->setIfExists('client_id', $data ?? [], null); + $this->setIfExists('files', $data ?? [], null); + $this->setIfExists('file_urls', $data ?? [], null); + $this->setIfExists('message', $data ?? [], null); + $this->setIfExists('subject', $data ?? [], null); + $this->setIfExists('test_mode', $data ?? [], false); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateUpdateFilesRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateUpdateFilesRequest { - /** @var TemplateUpdateFilesRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateUpdateFilesRequest */ + return ObjectSerializer::deserialize( $data, TemplateUpdateFilesRequest::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -281,6 +360,9 @@ public function getClientId() */ public function setClientId(?string $client_id) { + if (is_null($client_id)) { + throw new InvalidArgumentException('non-nullable client_id cannot be null'); + } $this->container['client_id'] = $client_id; return $this; @@ -305,6 +387,9 @@ public function getFiles() */ public function setFiles(?array $files) { + if (is_null($files)) { + throw new InvalidArgumentException('non-nullable files cannot be null'); + } $this->container['files'] = $files; return $this; @@ -329,6 +414,9 @@ public function getFileUrls() */ public function setFileUrls(?array $file_urls) { + if (is_null($file_urls)) { + throw new InvalidArgumentException('non-nullable file_urls cannot be null'); + } $this->container['file_urls'] = $file_urls; return $this; @@ -353,7 +441,10 @@ public function getMessage() */ public function setMessage(?string $message) { - if (!is_null($message) && (mb_strlen($message) > 5000)) { + if (is_null($message)) { + throw new InvalidArgumentException('non-nullable message cannot be null'); + } + if (mb_strlen($message) > 5000) { throw new InvalidArgumentException('invalid length for $message when calling TemplateUpdateFilesRequest., must be smaller than or equal to 5000.'); } @@ -381,7 +472,10 @@ public function getSubject() */ public function setSubject(?string $subject) { - if (!is_null($subject) && (mb_strlen($subject) > 100)) { + if (is_null($subject)) { + throw new InvalidArgumentException('non-nullable subject cannot be null'); + } + if (mb_strlen($subject) > 100) { throw new InvalidArgumentException('invalid length for $subject when calling TemplateUpdateFilesRequest., must be smaller than or equal to 100.'); } @@ -409,6 +503,9 @@ public function getTestMode() */ public function setTestMode(?bool $test_mode) { + if (is_null($test_mode)) { + throw new InvalidArgumentException('non-nullable test_mode cannot be null'); + } $this->container['test_mode'] = $test_mode; return $this; @@ -417,12 +514,10 @@ public function setTestMode(?bool $test_mode) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -430,7 +525,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -443,13 +538,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -461,12 +554,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -475,8 +566,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateUpdateFilesResponse.php b/sdks/php/src/Model/TemplateUpdateFilesResponse.php index b634cfbb2..c2a78f087 100644 --- a/sdks/php/src/Model/TemplateUpdateFilesResponse.php +++ b/sdks/php/src/Model/TemplateUpdateFilesResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * TemplateUpdateFilesResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class TemplateUpdateFilesResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -75,6 +71,22 @@ class TemplateUpdateFilesResponse implements ModelInterface, ArrayAccess, JsonSe 'template' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'template' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -95,6 +107,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -167,37 +223,55 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['template'] = $data['template'] ?? null; + $this->setIfExists('template', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateUpdateFilesResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateUpdateFilesResponse { - /** @var TemplateUpdateFilesResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateUpdateFilesResponse */ + return ObjectSerializer::deserialize( $data, TemplateUpdateFilesResponse::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -207,9 +281,7 @@ public static function init(array $data): TemplateUpdateFilesResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -242,6 +314,9 @@ public function getTemplate() */ public function setTemplate(?TemplateUpdateFilesResponseTemplate $template) { + if (is_null($template)) { + throw new InvalidArgumentException('non-nullable template cannot be null'); + } $this->container['template'] = $template; return $this; @@ -250,12 +325,10 @@ public function setTemplate(?TemplateUpdateFilesResponseTemplate $template) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -263,7 +336,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -276,13 +349,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -294,12 +365,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -308,8 +377,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/TemplateUpdateFilesResponseTemplate.php b/sdks/php/src/Model/TemplateUpdateFilesResponseTemplate.php index 4fb057faa..70d2e87dc 100644 --- a/sdks/php/src/Model/TemplateUpdateFilesResponseTemplate.php +++ b/sdks/php/src/Model/TemplateUpdateFilesResponseTemplate.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,12 +38,8 @@ * * @category Class * @description Contains template id - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class TemplateUpdateFilesResponseTemplate implements ModelInterface, ArrayAccess, JsonSerializable { @@ -78,6 +74,23 @@ class TemplateUpdateFilesResponseTemplate implements ModelInterface, ArrayAccess 'warnings' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'template_id' => false, + 'warnings' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -98,6 +111,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -173,38 +230,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['template_id'] = $data['template_id'] ?? null; - $this->container['warnings'] = $data['warnings'] ?? null; + $this->setIfExists('template_id', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): TemplateUpdateFilesResponseTemplate { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): TemplateUpdateFilesResponseTemplate { - /** @var TemplateUpdateFilesResponseTemplate $obj */ - $obj = ObjectSerializer::deserialize( + /** @var TemplateUpdateFilesResponseTemplate */ + return ObjectSerializer::deserialize( $data, TemplateUpdateFilesResponseTemplate::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -214,9 +289,7 @@ public static function init(array $data): TemplateUpdateFilesResponseTemplate */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -249,6 +322,9 @@ public function getTemplateId() */ public function setTemplateId(?string $template_id) { + if (is_null($template_id)) { + throw new InvalidArgumentException('non-nullable template_id cannot be null'); + } $this->container['template_id'] = $template_id; return $this; @@ -275,6 +351,9 @@ public function getWarnings() */ public function setWarnings(?array $warnings) { + if (is_null($warnings)) { + throw new InvalidArgumentException('non-nullable warnings cannot be null'); + } $this->container['warnings'] = $warnings; return $this; @@ -283,12 +362,10 @@ public function setWarnings(?array $warnings) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -296,7 +373,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -309,13 +386,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -327,12 +402,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -341,8 +414,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/UnclaimedDraftCreateEmbeddedRequest.php b/sdks/php/src/Model/UnclaimedDraftCreateEmbeddedRequest.php index 74a0a185b..8d4a7e3e2 100644 --- a/sdks/php/src/Model/UnclaimedDraftCreateEmbeddedRequest.php +++ b/sdks/php/src/Model/UnclaimedDraftCreateEmbeddedRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -39,11 +38,9 @@ * UnclaimedDraftCreateEmbeddedRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team + * @description * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class UnclaimedDraftCreateEmbeddedRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -146,6 +143,57 @@ class UnclaimedDraftCreateEmbeddedRequest implements ModelInterface, ArrayAccess 'expires_at' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'client_id' => false, + 'requester_email_address' => false, + 'files' => false, + 'file_urls' => false, + 'allow_ccs' => false, + 'allow_decline' => false, + 'allow_reassign' => false, + 'attachments' => false, + 'cc_email_addresses' => false, + 'custom_fields' => false, + 'editor_options' => false, + 'field_options' => false, + 'force_signer_page' => false, + 'force_subject_message' => false, + 'form_field_groups' => false, + 'form_field_rules' => false, + 'form_fields_per_document' => false, + 'hide_text_tags' => false, + 'hold_request' => false, + 'is_for_embedded_signing' => false, + 'message' => false, + 'metadata' => false, + 'requesting_redirect_url' => false, + 'show_preview' => false, + 'show_progress_stepper' => false, + 'signers' => false, + 'signing_options' => false, + 'signing_redirect_url' => false, + 'skip_me_now' => false, + 'subject' => false, + 'test_mode' => false, + 'type' => false, + 'use_preexisting_fields' => false, + 'use_text_tags' => false, + 'populate_auto_fill_fields' => false, + 'expires_at' => true, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -166,6 +214,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -359,72 +451,90 @@ public function getTypeAllowableValues() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['client_id'] = $data['client_id'] ?? null; - $this->container['requester_email_address'] = $data['requester_email_address'] ?? null; - $this->container['files'] = $data['files'] ?? null; - $this->container['file_urls'] = $data['file_urls'] ?? null; - $this->container['allow_ccs'] = $data['allow_ccs'] ?? true; - $this->container['allow_decline'] = $data['allow_decline'] ?? false; - $this->container['allow_reassign'] = $data['allow_reassign'] ?? false; - $this->container['attachments'] = $data['attachments'] ?? null; - $this->container['cc_email_addresses'] = $data['cc_email_addresses'] ?? null; - $this->container['custom_fields'] = $data['custom_fields'] ?? null; - $this->container['editor_options'] = $data['editor_options'] ?? null; - $this->container['field_options'] = $data['field_options'] ?? null; - $this->container['force_signer_page'] = $data['force_signer_page'] ?? false; - $this->container['force_subject_message'] = $data['force_subject_message'] ?? false; - $this->container['form_field_groups'] = $data['form_field_groups'] ?? null; - $this->container['form_field_rules'] = $data['form_field_rules'] ?? null; - $this->container['form_fields_per_document'] = $data['form_fields_per_document'] ?? null; - $this->container['hide_text_tags'] = $data['hide_text_tags'] ?? false; - $this->container['hold_request'] = $data['hold_request'] ?? false; - $this->container['is_for_embedded_signing'] = $data['is_for_embedded_signing'] ?? false; - $this->container['message'] = $data['message'] ?? null; - $this->container['metadata'] = $data['metadata'] ?? null; - $this->container['requesting_redirect_url'] = $data['requesting_redirect_url'] ?? null; - $this->container['show_preview'] = $data['show_preview'] ?? null; - $this->container['show_progress_stepper'] = $data['show_progress_stepper'] ?? true; - $this->container['signers'] = $data['signers'] ?? null; - $this->container['signing_options'] = $data['signing_options'] ?? null; - $this->container['signing_redirect_url'] = $data['signing_redirect_url'] ?? null; - $this->container['skip_me_now'] = $data['skip_me_now'] ?? false; - $this->container['subject'] = $data['subject'] ?? null; - $this->container['test_mode'] = $data['test_mode'] ?? false; - $this->container['type'] = $data['type'] ?? 'request_signature'; - $this->container['use_preexisting_fields'] = $data['use_preexisting_fields'] ?? false; - $this->container['use_text_tags'] = $data['use_text_tags'] ?? false; - $this->container['populate_auto_fill_fields'] = $data['populate_auto_fill_fields'] ?? false; - $this->container['expires_at'] = $data['expires_at'] ?? null; - } - - /** @deprecated use ::init() */ + $this->setIfExists('client_id', $data ?? [], null); + $this->setIfExists('requester_email_address', $data ?? [], null); + $this->setIfExists('files', $data ?? [], null); + $this->setIfExists('file_urls', $data ?? [], null); + $this->setIfExists('allow_ccs', $data ?? [], true); + $this->setIfExists('allow_decline', $data ?? [], false); + $this->setIfExists('allow_reassign', $data ?? [], false); + $this->setIfExists('attachments', $data ?? [], null); + $this->setIfExists('cc_email_addresses', $data ?? [], null); + $this->setIfExists('custom_fields', $data ?? [], null); + $this->setIfExists('editor_options', $data ?? [], null); + $this->setIfExists('field_options', $data ?? [], null); + $this->setIfExists('force_signer_page', $data ?? [], false); + $this->setIfExists('force_subject_message', $data ?? [], false); + $this->setIfExists('form_field_groups', $data ?? [], null); + $this->setIfExists('form_field_rules', $data ?? [], null); + $this->setIfExists('form_fields_per_document', $data ?? [], null); + $this->setIfExists('hide_text_tags', $data ?? [], false); + $this->setIfExists('hold_request', $data ?? [], false); + $this->setIfExists('is_for_embedded_signing', $data ?? [], false); + $this->setIfExists('message', $data ?? [], null); + $this->setIfExists('metadata', $data ?? [], null); + $this->setIfExists('requesting_redirect_url', $data ?? [], null); + $this->setIfExists('show_preview', $data ?? [], null); + $this->setIfExists('show_progress_stepper', $data ?? [], true); + $this->setIfExists('signers', $data ?? [], null); + $this->setIfExists('signing_options', $data ?? [], null); + $this->setIfExists('signing_redirect_url', $data ?? [], null); + $this->setIfExists('skip_me_now', $data ?? [], false); + $this->setIfExists('subject', $data ?? [], null); + $this->setIfExists('test_mode', $data ?? [], false); + $this->setIfExists('type', $data ?? [], 'request_signature'); + $this->setIfExists('use_preexisting_fields', $data ?? [], false); + $this->setIfExists('use_text_tags', $data ?? [], false); + $this->setIfExists('populate_auto_fill_fields', $data ?? [], false); + $this->setIfExists('expires_at', $data ?? [], null); + } + + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): UnclaimedDraftCreateEmbeddedRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): UnclaimedDraftCreateEmbeddedRequest { - /** @var UnclaimedDraftCreateEmbeddedRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var UnclaimedDraftCreateEmbeddedRequest */ + return ObjectSerializer::deserialize( $data, UnclaimedDraftCreateEmbeddedRequest::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -492,6 +602,9 @@ public function getClientId() */ public function setClientId(string $client_id) { + if (is_null($client_id)) { + throw new InvalidArgumentException('non-nullable client_id cannot be null'); + } $this->container['client_id'] = $client_id; return $this; @@ -516,6 +629,9 @@ public function getRequesterEmailAddress() */ public function setRequesterEmailAddress(string $requester_email_address) { + if (is_null($requester_email_address)) { + throw new InvalidArgumentException('non-nullable requester_email_address cannot be null'); + } $this->container['requester_email_address'] = $requester_email_address; return $this; @@ -540,6 +656,9 @@ public function getFiles() */ public function setFiles(?array $files) { + if (is_null($files)) { + throw new InvalidArgumentException('non-nullable files cannot be null'); + } $this->container['files'] = $files; return $this; @@ -564,6 +683,9 @@ public function getFileUrls() */ public function setFileUrls(?array $file_urls) { + if (is_null($file_urls)) { + throw new InvalidArgumentException('non-nullable file_urls cannot be null'); + } $this->container['file_urls'] = $file_urls; return $this; @@ -588,6 +710,9 @@ public function getAllowCcs() */ public function setAllowCcs(?bool $allow_ccs) { + if (is_null($allow_ccs)) { + throw new InvalidArgumentException('non-nullable allow_ccs cannot be null'); + } $this->container['allow_ccs'] = $allow_ccs; return $this; @@ -612,6 +737,9 @@ public function getAllowDecline() */ public function setAllowDecline(?bool $allow_decline) { + if (is_null($allow_decline)) { + throw new InvalidArgumentException('non-nullable allow_decline cannot be null'); + } $this->container['allow_decline'] = $allow_decline; return $this; @@ -636,6 +764,9 @@ public function getAllowReassign() */ public function setAllowReassign(?bool $allow_reassign) { + if (is_null($allow_reassign)) { + throw new InvalidArgumentException('non-nullable allow_reassign cannot be null'); + } $this->container['allow_reassign'] = $allow_reassign; return $this; @@ -660,6 +791,9 @@ public function getAttachments() */ public function setAttachments(?array $attachments) { + if (is_null($attachments)) { + throw new InvalidArgumentException('non-nullable attachments cannot be null'); + } $this->container['attachments'] = $attachments; return $this; @@ -684,6 +818,9 @@ public function getCcEmailAddresses() */ public function setCcEmailAddresses(?array $cc_email_addresses) { + if (is_null($cc_email_addresses)) { + throw new InvalidArgumentException('non-nullable cc_email_addresses cannot be null'); + } $this->container['cc_email_addresses'] = $cc_email_addresses; return $this; @@ -708,6 +845,9 @@ public function getCustomFields() */ public function setCustomFields(?array $custom_fields) { + if (is_null($custom_fields)) { + throw new InvalidArgumentException('non-nullable custom_fields cannot be null'); + } $this->container['custom_fields'] = $custom_fields; return $this; @@ -732,6 +872,9 @@ public function getEditorOptions() */ public function setEditorOptions(?SubEditorOptions $editor_options) { + if (is_null($editor_options)) { + throw new InvalidArgumentException('non-nullable editor_options cannot be null'); + } $this->container['editor_options'] = $editor_options; return $this; @@ -756,6 +899,9 @@ public function getFieldOptions() */ public function setFieldOptions(?SubFieldOptions $field_options) { + if (is_null($field_options)) { + throw new InvalidArgumentException('non-nullable field_options cannot be null'); + } $this->container['field_options'] = $field_options; return $this; @@ -780,6 +926,9 @@ public function getForceSignerPage() */ public function setForceSignerPage(?bool $force_signer_page) { + if (is_null($force_signer_page)) { + throw new InvalidArgumentException('non-nullable force_signer_page cannot be null'); + } $this->container['force_signer_page'] = $force_signer_page; return $this; @@ -804,6 +953,9 @@ public function getForceSubjectMessage() */ public function setForceSubjectMessage(?bool $force_subject_message) { + if (is_null($force_subject_message)) { + throw new InvalidArgumentException('non-nullable force_subject_message cannot be null'); + } $this->container['force_subject_message'] = $force_subject_message; return $this; @@ -828,6 +980,9 @@ public function getFormFieldGroups() */ public function setFormFieldGroups(?array $form_field_groups) { + if (is_null($form_field_groups)) { + throw new InvalidArgumentException('non-nullable form_field_groups cannot be null'); + } $this->container['form_field_groups'] = $form_field_groups; return $this; @@ -852,6 +1007,9 @@ public function getFormFieldRules() */ public function setFormFieldRules(?array $form_field_rules) { + if (is_null($form_field_rules)) { + throw new InvalidArgumentException('non-nullable form_field_rules cannot be null'); + } $this->container['form_field_rules'] = $form_field_rules; return $this; @@ -876,6 +1034,9 @@ public function getFormFieldsPerDocument() */ public function setFormFieldsPerDocument(?array $form_fields_per_document) { + if (is_null($form_fields_per_document)) { + throw new InvalidArgumentException('non-nullable form_fields_per_document cannot be null'); + } $this->container['form_fields_per_document'] = $form_fields_per_document; return $this; @@ -900,6 +1061,9 @@ public function getHideTextTags() */ public function setHideTextTags(?bool $hide_text_tags) { + if (is_null($hide_text_tags)) { + throw new InvalidArgumentException('non-nullable hide_text_tags cannot be null'); + } $this->container['hide_text_tags'] = $hide_text_tags; return $this; @@ -924,6 +1088,9 @@ public function getHoldRequest() */ public function setHoldRequest(?bool $hold_request) { + if (is_null($hold_request)) { + throw new InvalidArgumentException('non-nullable hold_request cannot be null'); + } $this->container['hold_request'] = $hold_request; return $this; @@ -948,6 +1115,9 @@ public function getIsForEmbeddedSigning() */ public function setIsForEmbeddedSigning(?bool $is_for_embedded_signing) { + if (is_null($is_for_embedded_signing)) { + throw new InvalidArgumentException('non-nullable is_for_embedded_signing cannot be null'); + } $this->container['is_for_embedded_signing'] = $is_for_embedded_signing; return $this; @@ -972,7 +1142,10 @@ public function getMessage() */ public function setMessage(?string $message) { - if (!is_null($message) && (mb_strlen($message) > 5000)) { + if (is_null($message)) { + throw new InvalidArgumentException('non-nullable message cannot be null'); + } + if (mb_strlen($message) > 5000) { throw new InvalidArgumentException('invalid length for $message when calling UnclaimedDraftCreateEmbeddedRequest., must be smaller than or equal to 5000.'); } @@ -1000,6 +1173,10 @@ public function getMetadata() */ public function setMetadata(?array $metadata) { + if (is_null($metadata)) { + throw new InvalidArgumentException('non-nullable metadata cannot be null'); + } + $this->container['metadata'] = $metadata; return $this; @@ -1024,6 +1201,9 @@ public function getRequestingRedirectUrl() */ public function setRequestingRedirectUrl(?string $requesting_redirect_url) { + if (is_null($requesting_redirect_url)) { + throw new InvalidArgumentException('non-nullable requesting_redirect_url cannot be null'); + } $this->container['requesting_redirect_url'] = $requesting_redirect_url; return $this; @@ -1048,6 +1228,9 @@ public function getShowPreview() */ public function setShowPreview(?bool $show_preview) { + if (is_null($show_preview)) { + throw new InvalidArgumentException('non-nullable show_preview cannot be null'); + } $this->container['show_preview'] = $show_preview; return $this; @@ -1072,6 +1255,9 @@ public function getShowProgressStepper() */ public function setShowProgressStepper(?bool $show_progress_stepper) { + if (is_null($show_progress_stepper)) { + throw new InvalidArgumentException('non-nullable show_progress_stepper cannot be null'); + } $this->container['show_progress_stepper'] = $show_progress_stepper; return $this; @@ -1096,6 +1282,9 @@ public function getSigners() */ public function setSigners(?array $signers) { + if (is_null($signers)) { + throw new InvalidArgumentException('non-nullable signers cannot be null'); + } $this->container['signers'] = $signers; return $this; @@ -1120,6 +1309,9 @@ public function getSigningOptions() */ public function setSigningOptions(?SubSigningOptions $signing_options) { + if (is_null($signing_options)) { + throw new InvalidArgumentException('non-nullable signing_options cannot be null'); + } $this->container['signing_options'] = $signing_options; return $this; @@ -1144,6 +1336,9 @@ public function getSigningRedirectUrl() */ public function setSigningRedirectUrl(?string $signing_redirect_url) { + if (is_null($signing_redirect_url)) { + throw new InvalidArgumentException('non-nullable signing_redirect_url cannot be null'); + } $this->container['signing_redirect_url'] = $signing_redirect_url; return $this; @@ -1168,6 +1363,9 @@ public function getSkipMeNow() */ public function setSkipMeNow(?bool $skip_me_now) { + if (is_null($skip_me_now)) { + throw new InvalidArgumentException('non-nullable skip_me_now cannot be null'); + } $this->container['skip_me_now'] = $skip_me_now; return $this; @@ -1192,7 +1390,10 @@ public function getSubject() */ public function setSubject(?string $subject) { - if (!is_null($subject) && (mb_strlen($subject) > 200)) { + if (is_null($subject)) { + throw new InvalidArgumentException('non-nullable subject cannot be null'); + } + if (mb_strlen($subject) > 200) { throw new InvalidArgumentException('invalid length for $subject when calling UnclaimedDraftCreateEmbeddedRequest., must be smaller than or equal to 200.'); } @@ -1220,6 +1421,9 @@ public function getTestMode() */ public function setTestMode(?bool $test_mode) { + if (is_null($test_mode)) { + throw new InvalidArgumentException('non-nullable test_mode cannot be null'); + } $this->container['test_mode'] = $test_mode; return $this; @@ -1244,8 +1448,11 @@ public function getType() */ public function setType(?string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $allowedValues = $this->getTypeAllowableValues(); - if (!is_null($type) && !in_array($type, $allowedValues, true)) { + if (!in_array($type, $allowedValues, true)) { throw new InvalidArgumentException( sprintf( "Invalid value '%s' for 'type', must be one of '%s'", @@ -1278,6 +1485,9 @@ public function getUsePreexistingFields() */ public function setUsePreexistingFields(?bool $use_preexisting_fields) { + if (is_null($use_preexisting_fields)) { + throw new InvalidArgumentException('non-nullable use_preexisting_fields cannot be null'); + } $this->container['use_preexisting_fields'] = $use_preexisting_fields; return $this; @@ -1302,6 +1512,9 @@ public function getUseTextTags() */ public function setUseTextTags(?bool $use_text_tags) { + if (is_null($use_text_tags)) { + throw new InvalidArgumentException('non-nullable use_text_tags cannot be null'); + } $this->container['use_text_tags'] = $use_text_tags; return $this; @@ -1326,6 +1539,9 @@ public function getPopulateAutoFillFields() */ public function setPopulateAutoFillFields(?bool $populate_auto_fill_fields) { + if (is_null($populate_auto_fill_fields)) { + throw new InvalidArgumentException('non-nullable populate_auto_fill_fields cannot be null'); + } $this->container['populate_auto_fill_fields'] = $populate_auto_fill_fields; return $this; @@ -1350,6 +1566,16 @@ public function getExpiresAt() */ public function setExpiresAt(?int $expires_at) { + if (is_null($expires_at)) { + array_push($this->openAPINullablesSetToNull, 'expires_at'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('expires_at', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['expires_at'] = $expires_at; return $this; @@ -1358,12 +1584,10 @@ public function setExpiresAt(?int $expires_at) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -1371,7 +1595,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -1384,13 +1608,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -1402,12 +1624,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -1416,8 +1636,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/UnclaimedDraftCreateEmbeddedWithTemplateRequest.php b/sdks/php/src/Model/UnclaimedDraftCreateEmbeddedWithTemplateRequest.php index d3cffebce..df0b1df69 100644 --- a/sdks/php/src/Model/UnclaimedDraftCreateEmbeddedWithTemplateRequest.php +++ b/sdks/php/src/Model/UnclaimedDraftCreateEmbeddedWithTemplateRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -39,11 +38,8 @@ * UnclaimedDraftCreateEmbeddedWithTemplateRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class UnclaimedDraftCreateEmbeddedWithTemplateRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -134,6 +130,51 @@ class UnclaimedDraftCreateEmbeddedWithTemplateRequest implements ModelInterface, 'allow_ccs' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'client_id' => false, + 'requester_email_address' => false, + 'template_ids' => false, + 'allow_decline' => false, + 'allow_reassign' => false, + 'ccs' => false, + 'custom_fields' => false, + 'editor_options' => false, + 'field_options' => false, + 'files' => false, + 'file_urls' => false, + 'force_signer_roles' => false, + 'force_subject_message' => false, + 'hold_request' => false, + 'is_for_embedded_signing' => false, + 'message' => false, + 'metadata' => false, + 'preview_only' => false, + 'requesting_redirect_url' => false, + 'show_preview' => false, + 'show_progress_stepper' => false, + 'signers' => false, + 'signing_options' => false, + 'signing_redirect_url' => false, + 'skip_me_now' => false, + 'subject' => false, + 'test_mode' => false, + 'title' => false, + 'populate_auto_fill_fields' => false, + 'allow_ccs' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -154,6 +195,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -313,66 +398,84 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['client_id'] = $data['client_id'] ?? null; - $this->container['requester_email_address'] = $data['requester_email_address'] ?? null; - $this->container['template_ids'] = $data['template_ids'] ?? null; - $this->container['allow_decline'] = $data['allow_decline'] ?? false; - $this->container['allow_reassign'] = $data['allow_reassign'] ?? false; - $this->container['ccs'] = $data['ccs'] ?? null; - $this->container['custom_fields'] = $data['custom_fields'] ?? null; - $this->container['editor_options'] = $data['editor_options'] ?? null; - $this->container['field_options'] = $data['field_options'] ?? null; - $this->container['files'] = $data['files'] ?? null; - $this->container['file_urls'] = $data['file_urls'] ?? null; - $this->container['force_signer_roles'] = $data['force_signer_roles'] ?? false; - $this->container['force_subject_message'] = $data['force_subject_message'] ?? false; - $this->container['hold_request'] = $data['hold_request'] ?? false; - $this->container['is_for_embedded_signing'] = $data['is_for_embedded_signing'] ?? false; - $this->container['message'] = $data['message'] ?? null; - $this->container['metadata'] = $data['metadata'] ?? null; - $this->container['preview_only'] = $data['preview_only'] ?? false; - $this->container['requesting_redirect_url'] = $data['requesting_redirect_url'] ?? null; - $this->container['show_preview'] = $data['show_preview'] ?? false; - $this->container['show_progress_stepper'] = $data['show_progress_stepper'] ?? true; - $this->container['signers'] = $data['signers'] ?? null; - $this->container['signing_options'] = $data['signing_options'] ?? null; - $this->container['signing_redirect_url'] = $data['signing_redirect_url'] ?? null; - $this->container['skip_me_now'] = $data['skip_me_now'] ?? false; - $this->container['subject'] = $data['subject'] ?? null; - $this->container['test_mode'] = $data['test_mode'] ?? false; - $this->container['title'] = $data['title'] ?? null; - $this->container['populate_auto_fill_fields'] = $data['populate_auto_fill_fields'] ?? false; - $this->container['allow_ccs'] = $data['allow_ccs'] ?? false; - } - - /** @deprecated use ::init() */ + $this->setIfExists('client_id', $data ?? [], null); + $this->setIfExists('requester_email_address', $data ?? [], null); + $this->setIfExists('template_ids', $data ?? [], null); + $this->setIfExists('allow_decline', $data ?? [], false); + $this->setIfExists('allow_reassign', $data ?? [], false); + $this->setIfExists('ccs', $data ?? [], null); + $this->setIfExists('custom_fields', $data ?? [], null); + $this->setIfExists('editor_options', $data ?? [], null); + $this->setIfExists('field_options', $data ?? [], null); + $this->setIfExists('files', $data ?? [], null); + $this->setIfExists('file_urls', $data ?? [], null); + $this->setIfExists('force_signer_roles', $data ?? [], false); + $this->setIfExists('force_subject_message', $data ?? [], false); + $this->setIfExists('hold_request', $data ?? [], false); + $this->setIfExists('is_for_embedded_signing', $data ?? [], false); + $this->setIfExists('message', $data ?? [], null); + $this->setIfExists('metadata', $data ?? [], null); + $this->setIfExists('preview_only', $data ?? [], false); + $this->setIfExists('requesting_redirect_url', $data ?? [], null); + $this->setIfExists('show_preview', $data ?? [], false); + $this->setIfExists('show_progress_stepper', $data ?? [], true); + $this->setIfExists('signers', $data ?? [], null); + $this->setIfExists('signing_options', $data ?? [], null); + $this->setIfExists('signing_redirect_url', $data ?? [], null); + $this->setIfExists('skip_me_now', $data ?? [], false); + $this->setIfExists('subject', $data ?? [], null); + $this->setIfExists('test_mode', $data ?? [], false); + $this->setIfExists('title', $data ?? [], null); + $this->setIfExists('populate_auto_fill_fields', $data ?? [], false); + $this->setIfExists('allow_ccs', $data ?? [], false); + } + + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): UnclaimedDraftCreateEmbeddedWithTemplateRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): UnclaimedDraftCreateEmbeddedWithTemplateRequest { - /** @var UnclaimedDraftCreateEmbeddedWithTemplateRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var UnclaimedDraftCreateEmbeddedWithTemplateRequest */ + return ObjectSerializer::deserialize( $data, UnclaimedDraftCreateEmbeddedWithTemplateRequest::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -438,6 +541,9 @@ public function getClientId() */ public function setClientId(string $client_id) { + if (is_null($client_id)) { + throw new InvalidArgumentException('non-nullable client_id cannot be null'); + } $this->container['client_id'] = $client_id; return $this; @@ -462,6 +568,9 @@ public function getRequesterEmailAddress() */ public function setRequesterEmailAddress(string $requester_email_address) { + if (is_null($requester_email_address)) { + throw new InvalidArgumentException('non-nullable requester_email_address cannot be null'); + } $this->container['requester_email_address'] = $requester_email_address; return $this; @@ -486,6 +595,9 @@ public function getTemplateIds() */ public function setTemplateIds(array $template_ids) { + if (is_null($template_ids)) { + throw new InvalidArgumentException('non-nullable template_ids cannot be null'); + } $this->container['template_ids'] = $template_ids; return $this; @@ -510,6 +622,9 @@ public function getAllowDecline() */ public function setAllowDecline(?bool $allow_decline) { + if (is_null($allow_decline)) { + throw new InvalidArgumentException('non-nullable allow_decline cannot be null'); + } $this->container['allow_decline'] = $allow_decline; return $this; @@ -534,6 +649,9 @@ public function getAllowReassign() */ public function setAllowReassign(?bool $allow_reassign) { + if (is_null($allow_reassign)) { + throw new InvalidArgumentException('non-nullable allow_reassign cannot be null'); + } $this->container['allow_reassign'] = $allow_reassign; return $this; @@ -558,6 +676,9 @@ public function getCcs() */ public function setCcs(?array $ccs) { + if (is_null($ccs)) { + throw new InvalidArgumentException('non-nullable ccs cannot be null'); + } $this->container['ccs'] = $ccs; return $this; @@ -582,6 +703,9 @@ public function getCustomFields() */ public function setCustomFields(?array $custom_fields) { + if (is_null($custom_fields)) { + throw new InvalidArgumentException('non-nullable custom_fields cannot be null'); + } $this->container['custom_fields'] = $custom_fields; return $this; @@ -606,6 +730,9 @@ public function getEditorOptions() */ public function setEditorOptions(?SubEditorOptions $editor_options) { + if (is_null($editor_options)) { + throw new InvalidArgumentException('non-nullable editor_options cannot be null'); + } $this->container['editor_options'] = $editor_options; return $this; @@ -630,6 +757,9 @@ public function getFieldOptions() */ public function setFieldOptions(?SubFieldOptions $field_options) { + if (is_null($field_options)) { + throw new InvalidArgumentException('non-nullable field_options cannot be null'); + } $this->container['field_options'] = $field_options; return $this; @@ -654,6 +784,9 @@ public function getFiles() */ public function setFiles(?array $files) { + if (is_null($files)) { + throw new InvalidArgumentException('non-nullable files cannot be null'); + } $this->container['files'] = $files; return $this; @@ -678,6 +811,9 @@ public function getFileUrls() */ public function setFileUrls(?array $file_urls) { + if (is_null($file_urls)) { + throw new InvalidArgumentException('non-nullable file_urls cannot be null'); + } $this->container['file_urls'] = $file_urls; return $this; @@ -702,6 +838,9 @@ public function getForceSignerRoles() */ public function setForceSignerRoles(?bool $force_signer_roles) { + if (is_null($force_signer_roles)) { + throw new InvalidArgumentException('non-nullable force_signer_roles cannot be null'); + } $this->container['force_signer_roles'] = $force_signer_roles; return $this; @@ -726,6 +865,9 @@ public function getForceSubjectMessage() */ public function setForceSubjectMessage(?bool $force_subject_message) { + if (is_null($force_subject_message)) { + throw new InvalidArgumentException('non-nullable force_subject_message cannot be null'); + } $this->container['force_subject_message'] = $force_subject_message; return $this; @@ -750,6 +892,9 @@ public function getHoldRequest() */ public function setHoldRequest(?bool $hold_request) { + if (is_null($hold_request)) { + throw new InvalidArgumentException('non-nullable hold_request cannot be null'); + } $this->container['hold_request'] = $hold_request; return $this; @@ -774,6 +919,9 @@ public function getIsForEmbeddedSigning() */ public function setIsForEmbeddedSigning(?bool $is_for_embedded_signing) { + if (is_null($is_for_embedded_signing)) { + throw new InvalidArgumentException('non-nullable is_for_embedded_signing cannot be null'); + } $this->container['is_for_embedded_signing'] = $is_for_embedded_signing; return $this; @@ -798,7 +946,10 @@ public function getMessage() */ public function setMessage(?string $message) { - if (!is_null($message) && (mb_strlen($message) > 5000)) { + if (is_null($message)) { + throw new InvalidArgumentException('non-nullable message cannot be null'); + } + if (mb_strlen($message) > 5000) { throw new InvalidArgumentException('invalid length for $message when calling UnclaimedDraftCreateEmbeddedWithTemplateRequest., must be smaller than or equal to 5000.'); } @@ -826,6 +977,10 @@ public function getMetadata() */ public function setMetadata(?array $metadata) { + if (is_null($metadata)) { + throw new InvalidArgumentException('non-nullable metadata cannot be null'); + } + $this->container['metadata'] = $metadata; return $this; @@ -850,6 +1005,9 @@ public function getPreviewOnly() */ public function setPreviewOnly(?bool $preview_only) { + if (is_null($preview_only)) { + throw new InvalidArgumentException('non-nullable preview_only cannot be null'); + } $this->container['preview_only'] = $preview_only; return $this; @@ -874,6 +1032,9 @@ public function getRequestingRedirectUrl() */ public function setRequestingRedirectUrl(?string $requesting_redirect_url) { + if (is_null($requesting_redirect_url)) { + throw new InvalidArgumentException('non-nullable requesting_redirect_url cannot be null'); + } $this->container['requesting_redirect_url'] = $requesting_redirect_url; return $this; @@ -898,6 +1059,9 @@ public function getShowPreview() */ public function setShowPreview(?bool $show_preview) { + if (is_null($show_preview)) { + throw new InvalidArgumentException('non-nullable show_preview cannot be null'); + } $this->container['show_preview'] = $show_preview; return $this; @@ -922,6 +1086,9 @@ public function getShowProgressStepper() */ public function setShowProgressStepper(?bool $show_progress_stepper) { + if (is_null($show_progress_stepper)) { + throw new InvalidArgumentException('non-nullable show_progress_stepper cannot be null'); + } $this->container['show_progress_stepper'] = $show_progress_stepper; return $this; @@ -946,6 +1113,9 @@ public function getSigners() */ public function setSigners(?array $signers) { + if (is_null($signers)) { + throw new InvalidArgumentException('non-nullable signers cannot be null'); + } $this->container['signers'] = $signers; return $this; @@ -970,6 +1140,9 @@ public function getSigningOptions() */ public function setSigningOptions(?SubSigningOptions $signing_options) { + if (is_null($signing_options)) { + throw new InvalidArgumentException('non-nullable signing_options cannot be null'); + } $this->container['signing_options'] = $signing_options; return $this; @@ -994,6 +1167,9 @@ public function getSigningRedirectUrl() */ public function setSigningRedirectUrl(?string $signing_redirect_url) { + if (is_null($signing_redirect_url)) { + throw new InvalidArgumentException('non-nullable signing_redirect_url cannot be null'); + } $this->container['signing_redirect_url'] = $signing_redirect_url; return $this; @@ -1018,6 +1194,9 @@ public function getSkipMeNow() */ public function setSkipMeNow(?bool $skip_me_now) { + if (is_null($skip_me_now)) { + throw new InvalidArgumentException('non-nullable skip_me_now cannot be null'); + } $this->container['skip_me_now'] = $skip_me_now; return $this; @@ -1042,7 +1221,10 @@ public function getSubject() */ public function setSubject(?string $subject) { - if (!is_null($subject) && (mb_strlen($subject) > 255)) { + if (is_null($subject)) { + throw new InvalidArgumentException('non-nullable subject cannot be null'); + } + if (mb_strlen($subject) > 255) { throw new InvalidArgumentException('invalid length for $subject when calling UnclaimedDraftCreateEmbeddedWithTemplateRequest., must be smaller than or equal to 255.'); } @@ -1070,6 +1252,9 @@ public function getTestMode() */ public function setTestMode(?bool $test_mode) { + if (is_null($test_mode)) { + throw new InvalidArgumentException('non-nullable test_mode cannot be null'); + } $this->container['test_mode'] = $test_mode; return $this; @@ -1094,7 +1279,10 @@ public function getTitle() */ public function setTitle(?string $title) { - if (!is_null($title) && (mb_strlen($title) > 255)) { + if (is_null($title)) { + throw new InvalidArgumentException('non-nullable title cannot be null'); + } + if (mb_strlen($title) > 255) { throw new InvalidArgumentException('invalid length for $title when calling UnclaimedDraftCreateEmbeddedWithTemplateRequest., must be smaller than or equal to 255.'); } @@ -1122,6 +1310,9 @@ public function getPopulateAutoFillFields() */ public function setPopulateAutoFillFields(?bool $populate_auto_fill_fields) { + if (is_null($populate_auto_fill_fields)) { + throw new InvalidArgumentException('non-nullable populate_auto_fill_fields cannot be null'); + } $this->container['populate_auto_fill_fields'] = $populate_auto_fill_fields; return $this; @@ -1146,6 +1337,9 @@ public function getAllowCcs() */ public function setAllowCcs(?bool $allow_ccs) { + if (is_null($allow_ccs)) { + throw new InvalidArgumentException('non-nullable allow_ccs cannot be null'); + } $this->container['allow_ccs'] = $allow_ccs; return $this; @@ -1154,12 +1348,10 @@ public function setAllowCcs(?bool $allow_ccs) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -1167,7 +1359,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -1180,13 +1372,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -1198,12 +1388,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -1212,8 +1400,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/UnclaimedDraftCreateRequest.php b/sdks/php/src/Model/UnclaimedDraftCreateRequest.php index 3eaaa3840..1d55c2c1b 100644 --- a/sdks/php/src/Model/UnclaimedDraftCreateRequest.php +++ b/sdks/php/src/Model/UnclaimedDraftCreateRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -39,11 +38,9 @@ * UnclaimedDraftCreateRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team + * @description * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class UnclaimedDraftCreateRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -122,6 +119,45 @@ class UnclaimedDraftCreateRequest implements ModelInterface, ArrayAccess, JsonSe 'expires_at' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'files' => false, + 'file_urls' => false, + 'allow_decline' => false, + 'attachments' => false, + 'cc_email_addresses' => false, + 'client_id' => false, + 'custom_fields' => false, + 'field_options' => false, + 'form_field_groups' => false, + 'form_field_rules' => false, + 'form_fields_per_document' => false, + 'hide_text_tags' => false, + 'message' => false, + 'metadata' => false, + 'show_progress_stepper' => false, + 'signers' => false, + 'signing_options' => false, + 'signing_redirect_url' => false, + 'subject' => false, + 'test_mode' => false, + 'use_preexisting_fields' => false, + 'use_text_tags' => false, + 'expires_at' => true, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -142,6 +178,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -299,60 +379,78 @@ public function getTypeAllowableValues() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['type'] = $data['type'] ?? null; - $this->container['files'] = $data['files'] ?? null; - $this->container['file_urls'] = $data['file_urls'] ?? null; - $this->container['allow_decline'] = $data['allow_decline'] ?? false; - $this->container['attachments'] = $data['attachments'] ?? null; - $this->container['cc_email_addresses'] = $data['cc_email_addresses'] ?? null; - $this->container['client_id'] = $data['client_id'] ?? null; - $this->container['custom_fields'] = $data['custom_fields'] ?? null; - $this->container['field_options'] = $data['field_options'] ?? null; - $this->container['form_field_groups'] = $data['form_field_groups'] ?? null; - $this->container['form_field_rules'] = $data['form_field_rules'] ?? null; - $this->container['form_fields_per_document'] = $data['form_fields_per_document'] ?? null; - $this->container['hide_text_tags'] = $data['hide_text_tags'] ?? false; - $this->container['message'] = $data['message'] ?? null; - $this->container['metadata'] = $data['metadata'] ?? null; - $this->container['show_progress_stepper'] = $data['show_progress_stepper'] ?? true; - $this->container['signers'] = $data['signers'] ?? null; - $this->container['signing_options'] = $data['signing_options'] ?? null; - $this->container['signing_redirect_url'] = $data['signing_redirect_url'] ?? null; - $this->container['subject'] = $data['subject'] ?? null; - $this->container['test_mode'] = $data['test_mode'] ?? false; - $this->container['use_preexisting_fields'] = $data['use_preexisting_fields'] ?? false; - $this->container['use_text_tags'] = $data['use_text_tags'] ?? false; - $this->container['expires_at'] = $data['expires_at'] ?? null; - } - - /** @deprecated use ::init() */ + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('files', $data ?? [], null); + $this->setIfExists('file_urls', $data ?? [], null); + $this->setIfExists('allow_decline', $data ?? [], false); + $this->setIfExists('attachments', $data ?? [], null); + $this->setIfExists('cc_email_addresses', $data ?? [], null); + $this->setIfExists('client_id', $data ?? [], null); + $this->setIfExists('custom_fields', $data ?? [], null); + $this->setIfExists('field_options', $data ?? [], null); + $this->setIfExists('form_field_groups', $data ?? [], null); + $this->setIfExists('form_field_rules', $data ?? [], null); + $this->setIfExists('form_fields_per_document', $data ?? [], null); + $this->setIfExists('hide_text_tags', $data ?? [], false); + $this->setIfExists('message', $data ?? [], null); + $this->setIfExists('metadata', $data ?? [], null); + $this->setIfExists('show_progress_stepper', $data ?? [], true); + $this->setIfExists('signers', $data ?? [], null); + $this->setIfExists('signing_options', $data ?? [], null); + $this->setIfExists('signing_redirect_url', $data ?? [], null); + $this->setIfExists('subject', $data ?? [], null); + $this->setIfExists('test_mode', $data ?? [], false); + $this->setIfExists('use_preexisting_fields', $data ?? [], false); + $this->setIfExists('use_text_tags', $data ?? [], false); + $this->setIfExists('expires_at', $data ?? [], null); + } + + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): UnclaimedDraftCreateRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): UnclaimedDraftCreateRequest { - /** @var UnclaimedDraftCreateRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var UnclaimedDraftCreateRequest */ + return ObjectSerializer::deserialize( $data, UnclaimedDraftCreateRequest::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -417,6 +515,9 @@ public function getType() */ public function setType(string $type) { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } $allowedValues = $this->getTypeAllowableValues(); if (!in_array($type, $allowedValues, true)) { throw new InvalidArgumentException( @@ -451,6 +552,9 @@ public function getFiles() */ public function setFiles(?array $files) { + if (is_null($files)) { + throw new InvalidArgumentException('non-nullable files cannot be null'); + } $this->container['files'] = $files; return $this; @@ -475,6 +579,9 @@ public function getFileUrls() */ public function setFileUrls(?array $file_urls) { + if (is_null($file_urls)) { + throw new InvalidArgumentException('non-nullable file_urls cannot be null'); + } $this->container['file_urls'] = $file_urls; return $this; @@ -499,6 +606,9 @@ public function getAllowDecline() */ public function setAllowDecline(?bool $allow_decline) { + if (is_null($allow_decline)) { + throw new InvalidArgumentException('non-nullable allow_decline cannot be null'); + } $this->container['allow_decline'] = $allow_decline; return $this; @@ -523,6 +633,9 @@ public function getAttachments() */ public function setAttachments(?array $attachments) { + if (is_null($attachments)) { + throw new InvalidArgumentException('non-nullable attachments cannot be null'); + } $this->container['attachments'] = $attachments; return $this; @@ -547,6 +660,9 @@ public function getCcEmailAddresses() */ public function setCcEmailAddresses(?array $cc_email_addresses) { + if (is_null($cc_email_addresses)) { + throw new InvalidArgumentException('non-nullable cc_email_addresses cannot be null'); + } $this->container['cc_email_addresses'] = $cc_email_addresses; return $this; @@ -571,6 +687,9 @@ public function getClientId() */ public function setClientId(?string $client_id) { + if (is_null($client_id)) { + throw new InvalidArgumentException('non-nullable client_id cannot be null'); + } $this->container['client_id'] = $client_id; return $this; @@ -595,6 +714,9 @@ public function getCustomFields() */ public function setCustomFields(?array $custom_fields) { + if (is_null($custom_fields)) { + throw new InvalidArgumentException('non-nullable custom_fields cannot be null'); + } $this->container['custom_fields'] = $custom_fields; return $this; @@ -619,6 +741,9 @@ public function getFieldOptions() */ public function setFieldOptions(?SubFieldOptions $field_options) { + if (is_null($field_options)) { + throw new InvalidArgumentException('non-nullable field_options cannot be null'); + } $this->container['field_options'] = $field_options; return $this; @@ -643,6 +768,9 @@ public function getFormFieldGroups() */ public function setFormFieldGroups(?array $form_field_groups) { + if (is_null($form_field_groups)) { + throw new InvalidArgumentException('non-nullable form_field_groups cannot be null'); + } $this->container['form_field_groups'] = $form_field_groups; return $this; @@ -667,6 +795,9 @@ public function getFormFieldRules() */ public function setFormFieldRules(?array $form_field_rules) { + if (is_null($form_field_rules)) { + throw new InvalidArgumentException('non-nullable form_field_rules cannot be null'); + } $this->container['form_field_rules'] = $form_field_rules; return $this; @@ -691,6 +822,9 @@ public function getFormFieldsPerDocument() */ public function setFormFieldsPerDocument(?array $form_fields_per_document) { + if (is_null($form_fields_per_document)) { + throw new InvalidArgumentException('non-nullable form_fields_per_document cannot be null'); + } $this->container['form_fields_per_document'] = $form_fields_per_document; return $this; @@ -715,6 +849,9 @@ public function getHideTextTags() */ public function setHideTextTags(?bool $hide_text_tags) { + if (is_null($hide_text_tags)) { + throw new InvalidArgumentException('non-nullable hide_text_tags cannot be null'); + } $this->container['hide_text_tags'] = $hide_text_tags; return $this; @@ -739,7 +876,10 @@ public function getMessage() */ public function setMessage(?string $message) { - if (!is_null($message) && (mb_strlen($message) > 5000)) { + if (is_null($message)) { + throw new InvalidArgumentException('non-nullable message cannot be null'); + } + if (mb_strlen($message) > 5000) { throw new InvalidArgumentException('invalid length for $message when calling UnclaimedDraftCreateRequest., must be smaller than or equal to 5000.'); } @@ -767,6 +907,10 @@ public function getMetadata() */ public function setMetadata(?array $metadata) { + if (is_null($metadata)) { + throw new InvalidArgumentException('non-nullable metadata cannot be null'); + } + $this->container['metadata'] = $metadata; return $this; @@ -791,6 +935,9 @@ public function getShowProgressStepper() */ public function setShowProgressStepper(?bool $show_progress_stepper) { + if (is_null($show_progress_stepper)) { + throw new InvalidArgumentException('non-nullable show_progress_stepper cannot be null'); + } $this->container['show_progress_stepper'] = $show_progress_stepper; return $this; @@ -815,6 +962,9 @@ public function getSigners() */ public function setSigners(?array $signers) { + if (is_null($signers)) { + throw new InvalidArgumentException('non-nullable signers cannot be null'); + } $this->container['signers'] = $signers; return $this; @@ -839,6 +989,9 @@ public function getSigningOptions() */ public function setSigningOptions(?SubSigningOptions $signing_options) { + if (is_null($signing_options)) { + throw new InvalidArgumentException('non-nullable signing_options cannot be null'); + } $this->container['signing_options'] = $signing_options; return $this; @@ -863,6 +1016,9 @@ public function getSigningRedirectUrl() */ public function setSigningRedirectUrl(?string $signing_redirect_url) { + if (is_null($signing_redirect_url)) { + throw new InvalidArgumentException('non-nullable signing_redirect_url cannot be null'); + } $this->container['signing_redirect_url'] = $signing_redirect_url; return $this; @@ -887,7 +1043,10 @@ public function getSubject() */ public function setSubject(?string $subject) { - if (!is_null($subject) && (mb_strlen($subject) > 200)) { + if (is_null($subject)) { + throw new InvalidArgumentException('non-nullable subject cannot be null'); + } + if (mb_strlen($subject) > 200) { throw new InvalidArgumentException('invalid length for $subject when calling UnclaimedDraftCreateRequest., must be smaller than or equal to 200.'); } @@ -915,6 +1074,9 @@ public function getTestMode() */ public function setTestMode(?bool $test_mode) { + if (is_null($test_mode)) { + throw new InvalidArgumentException('non-nullable test_mode cannot be null'); + } $this->container['test_mode'] = $test_mode; return $this; @@ -939,6 +1101,9 @@ public function getUsePreexistingFields() */ public function setUsePreexistingFields(?bool $use_preexisting_fields) { + if (is_null($use_preexisting_fields)) { + throw new InvalidArgumentException('non-nullable use_preexisting_fields cannot be null'); + } $this->container['use_preexisting_fields'] = $use_preexisting_fields; return $this; @@ -963,6 +1128,9 @@ public function getUseTextTags() */ public function setUseTextTags(?bool $use_text_tags) { + if (is_null($use_text_tags)) { + throw new InvalidArgumentException('non-nullable use_text_tags cannot be null'); + } $this->container['use_text_tags'] = $use_text_tags; return $this; @@ -987,6 +1155,16 @@ public function getExpiresAt() */ public function setExpiresAt(?int $expires_at) { + if (is_null($expires_at)) { + array_push($this->openAPINullablesSetToNull, 'expires_at'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('expires_at', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['expires_at'] = $expires_at; return $this; @@ -995,12 +1173,10 @@ public function setExpiresAt(?int $expires_at) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -1008,7 +1184,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -1021,13 +1197,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -1039,12 +1213,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -1053,8 +1225,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/UnclaimedDraftCreateResponse.php b/sdks/php/src/Model/UnclaimedDraftCreateResponse.php index a055a5c4c..fa8831416 100644 --- a/sdks/php/src/Model/UnclaimedDraftCreateResponse.php +++ b/sdks/php/src/Model/UnclaimedDraftCreateResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,12 +37,8 @@ * UnclaimedDraftCreateResponse Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class UnclaimedDraftCreateResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -77,6 +73,23 @@ class UnclaimedDraftCreateResponse implements ModelInterface, ArrayAccess, JsonS 'warnings' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'unclaimed_draft' => false, + 'warnings' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -97,6 +110,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -172,38 +229,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['unclaimed_draft'] = $data['unclaimed_draft'] ?? null; - $this->container['warnings'] = $data['warnings'] ?? null; + $this->setIfExists('unclaimed_draft', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): UnclaimedDraftCreateResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): UnclaimedDraftCreateResponse { - /** @var UnclaimedDraftCreateResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var UnclaimedDraftCreateResponse */ + return ObjectSerializer::deserialize( $data, UnclaimedDraftCreateResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -213,9 +288,7 @@ public static function init(array $data): UnclaimedDraftCreateResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -248,6 +321,9 @@ public function getUnclaimedDraft() */ public function setUnclaimedDraft(?UnclaimedDraftResponse $unclaimed_draft) { + if (is_null($unclaimed_draft)) { + throw new InvalidArgumentException('non-nullable unclaimed_draft cannot be null'); + } $this->container['unclaimed_draft'] = $unclaimed_draft; return $this; @@ -272,6 +348,9 @@ public function getWarnings() */ public function setWarnings(?array $warnings) { + if (is_null($warnings)) { + throw new InvalidArgumentException('non-nullable warnings cannot be null'); + } $this->container['warnings'] = $warnings; return $this; @@ -280,12 +359,10 @@ public function setWarnings(?array $warnings) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -293,7 +370,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -306,13 +383,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -324,12 +399,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -338,8 +411,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/UnclaimedDraftEditAndResendRequest.php b/sdks/php/src/Model/UnclaimedDraftEditAndResendRequest.php index 3e15395f8..5669e4848 100644 --- a/sdks/php/src/Model/UnclaimedDraftEditAndResendRequest.php +++ b/sdks/php/src/Model/UnclaimedDraftEditAndResendRequest.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -37,11 +37,8 @@ * UnclaimedDraftEditAndResendRequest Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class UnclaimedDraftEditAndResendRequest implements ModelInterface, ArrayAccess, JsonSerializable { @@ -88,6 +85,29 @@ class UnclaimedDraftEditAndResendRequest implements ModelInterface, ArrayAccess, 'test_mode' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'client_id' => false, + 'editor_options' => false, + 'is_for_embedded_signing' => false, + 'requester_email_address' => false, + 'requesting_redirect_url' => false, + 'show_progress_stepper' => false, + 'signing_redirect_url' => false, + 'test_mode' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -108,6 +128,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -201,44 +265,62 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['client_id'] = $data['client_id'] ?? null; - $this->container['editor_options'] = $data['editor_options'] ?? null; - $this->container['is_for_embedded_signing'] = $data['is_for_embedded_signing'] ?? null; - $this->container['requester_email_address'] = $data['requester_email_address'] ?? null; - $this->container['requesting_redirect_url'] = $data['requesting_redirect_url'] ?? null; - $this->container['show_progress_stepper'] = $data['show_progress_stepper'] ?? true; - $this->container['signing_redirect_url'] = $data['signing_redirect_url'] ?? null; - $this->container['test_mode'] = $data['test_mode'] ?? false; + $this->setIfExists('client_id', $data ?? [], null); + $this->setIfExists('editor_options', $data ?? [], null); + $this->setIfExists('is_for_embedded_signing', $data ?? [], null); + $this->setIfExists('requester_email_address', $data ?? [], null); + $this->setIfExists('requesting_redirect_url', $data ?? [], null); + $this->setIfExists('show_progress_stepper', $data ?? [], true); + $this->setIfExists('signing_redirect_url', $data ?? [], null); + $this->setIfExists('test_mode', $data ?? [], false); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): UnclaimedDraftEditAndResendRequest { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): UnclaimedDraftEditAndResendRequest { - /** @var UnclaimedDraftEditAndResendRequest $obj */ - $obj = ObjectSerializer::deserialize( + /** @var UnclaimedDraftEditAndResendRequest */ + return ObjectSerializer::deserialize( $data, UnclaimedDraftEditAndResendRequest::class, ); + } - return $obj; + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -253,7 +335,6 @@ public function listInvalidProperties() if ($this->container['client_id'] === null) { $invalidProperties[] = "'client_id' can't be null"; } - return $invalidProperties; } @@ -287,6 +368,9 @@ public function getClientId() */ public function setClientId(string $client_id) { + if (is_null($client_id)) { + throw new InvalidArgumentException('non-nullable client_id cannot be null'); + } $this->container['client_id'] = $client_id; return $this; @@ -311,6 +395,9 @@ public function getEditorOptions() */ public function setEditorOptions(?SubEditorOptions $editor_options) { + if (is_null($editor_options)) { + throw new InvalidArgumentException('non-nullable editor_options cannot be null'); + } $this->container['editor_options'] = $editor_options; return $this; @@ -335,6 +422,9 @@ public function getIsForEmbeddedSigning() */ public function setIsForEmbeddedSigning(?bool $is_for_embedded_signing) { + if (is_null($is_for_embedded_signing)) { + throw new InvalidArgumentException('non-nullable is_for_embedded_signing cannot be null'); + } $this->container['is_for_embedded_signing'] = $is_for_embedded_signing; return $this; @@ -359,6 +449,9 @@ public function getRequesterEmailAddress() */ public function setRequesterEmailAddress(?string $requester_email_address) { + if (is_null($requester_email_address)) { + throw new InvalidArgumentException('non-nullable requester_email_address cannot be null'); + } $this->container['requester_email_address'] = $requester_email_address; return $this; @@ -383,6 +476,9 @@ public function getRequestingRedirectUrl() */ public function setRequestingRedirectUrl(?string $requesting_redirect_url) { + if (is_null($requesting_redirect_url)) { + throw new InvalidArgumentException('non-nullable requesting_redirect_url cannot be null'); + } $this->container['requesting_redirect_url'] = $requesting_redirect_url; return $this; @@ -407,6 +503,9 @@ public function getShowProgressStepper() */ public function setShowProgressStepper(?bool $show_progress_stepper) { + if (is_null($show_progress_stepper)) { + throw new InvalidArgumentException('non-nullable show_progress_stepper cannot be null'); + } $this->container['show_progress_stepper'] = $show_progress_stepper; return $this; @@ -431,6 +530,9 @@ public function getSigningRedirectUrl() */ public function setSigningRedirectUrl(?string $signing_redirect_url) { + if (is_null($signing_redirect_url)) { + throw new InvalidArgumentException('non-nullable signing_redirect_url cannot be null'); + } $this->container['signing_redirect_url'] = $signing_redirect_url; return $this; @@ -455,6 +557,9 @@ public function getTestMode() */ public function setTestMode(?bool $test_mode) { + if (is_null($test_mode)) { + throw new InvalidArgumentException('non-nullable test_mode cannot be null'); + } $this->container['test_mode'] = $test_mode; return $this; @@ -463,12 +568,10 @@ public function setTestMode(?bool $test_mode) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -476,7 +579,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -489,13 +592,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -507,12 +608,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -521,8 +620,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/UnclaimedDraftResponse.php b/sdks/php/src/Model/UnclaimedDraftResponse.php index 8586ad99b..da1c26359 100644 --- a/sdks/php/src/Model/UnclaimedDraftResponse.php +++ b/sdks/php/src/Model/UnclaimedDraftResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,12 +38,8 @@ * * @category Class * @description A group of documents that a user can take ownership of via the claim URL. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null - * @internal This class should not be instantiated directly + * @implements \ArrayAccess */ class UnclaimedDraftResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -86,6 +82,27 @@ class UnclaimedDraftResponse implements ModelInterface, ArrayAccess, JsonSeriali 'test_mode' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'signature_request_id' => true, + 'claim_url' => false, + 'signing_redirect_url' => true, + 'requesting_redirect_url' => true, + 'expires_at' => true, + 'test_mode' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -106,6 +123,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -193,42 +254,60 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['signature_request_id'] = $data['signature_request_id'] ?? null; - $this->container['claim_url'] = $data['claim_url'] ?? null; - $this->container['signing_redirect_url'] = $data['signing_redirect_url'] ?? null; - $this->container['requesting_redirect_url'] = $data['requesting_redirect_url'] ?? null; - $this->container['expires_at'] = $data['expires_at'] ?? null; - $this->container['test_mode'] = $data['test_mode'] ?? null; + $this->setIfExists('signature_request_id', $data ?? [], null); + $this->setIfExists('claim_url', $data ?? [], null); + $this->setIfExists('signing_redirect_url', $data ?? [], null); + $this->setIfExists('requesting_redirect_url', $data ?? [], null); + $this->setIfExists('expires_at', $data ?? [], null); + $this->setIfExists('test_mode', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): UnclaimedDraftResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): UnclaimedDraftResponse { - /** @var UnclaimedDraftResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var UnclaimedDraftResponse */ + return ObjectSerializer::deserialize( $data, UnclaimedDraftResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -238,9 +317,7 @@ public static function init(array $data): UnclaimedDraftResponse */ public function listInvalidProperties() { - $invalidProperties = []; - - return $invalidProperties; + return []; } /** @@ -273,6 +350,16 @@ public function getSignatureRequestId() */ public function setSignatureRequestId(?string $signature_request_id) { + if (is_null($signature_request_id)) { + array_push($this->openAPINullablesSetToNull, 'signature_request_id'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('signature_request_id', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['signature_request_id'] = $signature_request_id; return $this; @@ -297,6 +384,9 @@ public function getClaimUrl() */ public function setClaimUrl(?string $claim_url) { + if (is_null($claim_url)) { + throw new InvalidArgumentException('non-nullable claim_url cannot be null'); + } $this->container['claim_url'] = $claim_url; return $this; @@ -321,6 +411,16 @@ public function getSigningRedirectUrl() */ public function setSigningRedirectUrl(?string $signing_redirect_url) { + if (is_null($signing_redirect_url)) { + array_push($this->openAPINullablesSetToNull, 'signing_redirect_url'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('signing_redirect_url', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['signing_redirect_url'] = $signing_redirect_url; return $this; @@ -345,6 +445,16 @@ public function getRequestingRedirectUrl() */ public function setRequestingRedirectUrl(?string $requesting_redirect_url) { + if (is_null($requesting_redirect_url)) { + array_push($this->openAPINullablesSetToNull, 'requesting_redirect_url'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('requesting_redirect_url', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['requesting_redirect_url'] = $requesting_redirect_url; return $this; @@ -369,6 +479,16 @@ public function getExpiresAt() */ public function setExpiresAt(?int $expires_at) { + if (is_null($expires_at)) { + array_push($this->openAPINullablesSetToNull, 'expires_at'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('expires_at', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } $this->container['expires_at'] = $expires_at; return $this; @@ -393,6 +513,9 @@ public function getTestMode() */ public function setTestMode(?bool $test_mode) { + if (is_null($test_mode)) { + throw new InvalidArgumentException('non-nullable test_mode cannot be null'); + } $this->container['test_mode'] = $test_mode; return $this; @@ -401,12 +524,10 @@ public function setTestMode(?bool $test_mode) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -414,7 +535,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -427,13 +548,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -445,12 +564,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -459,8 +576,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/Model/WarningResponse.php b/sdks/php/src/Model/WarningResponse.php index 08efacdc0..4c37010a0 100644 --- a/sdks/php/src/Model/WarningResponse.php +++ b/sdks/php/src/Model/WarningResponse.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -30,6 +29,7 @@ use ArrayAccess; use Dropbox\Sign\ObjectSerializer; +use InvalidArgumentException; use JsonSerializable; use ReturnTypeWillChange; @@ -38,11 +38,8 @@ * * @category Class * @description A list of warnings. - * @author OpenAPI Generator team * @see https://openapi-generator.tech - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess */ class WarningResponse implements ModelInterface, ArrayAccess, JsonSerializable { @@ -77,6 +74,23 @@ class WarningResponse implements ModelInterface, ArrayAccess, JsonSerializable 'warning_name' => null, ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'warning_msg' => false, + 'warning_name' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -97,6 +111,50 @@ public static function openAPIFormats() return self::$openAPIFormats; } + /** + * Array of nullable properties + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -172,38 +230,56 @@ public function getModelName() /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; /** * Constructor * - * @param array|null $data Associated array of property values - * initializing the model + * @param mixed[] $data Associated array of property values + * initializing the model */ public function __construct(array $data = null) { - $this->container['warning_msg'] = $data['warning_msg'] ?? null; - $this->container['warning_name'] = $data['warning_name'] ?? null; + $this->setIfExists('warning_msg', $data ?? [], null); + $this->setIfExists('warning_name', $data ?? [], null); } - /** @deprecated use ::init() */ + /** + * @deprecated use ::init() + */ public static function fromArray(array $data): WarningResponse { return self::init($data); } - /** Attempt to instantiate and hydrate a new instance of this class */ + /** + * Attempt to instantiate and hydrate a new instance of this class + */ public static function init(array $data): WarningResponse { - /** @var WarningResponse $obj */ - $obj = ObjectSerializer::deserialize( + /** @var WarningResponse */ + return ObjectSerializer::deserialize( $data, WarningResponse::class, ); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string|int|object|array|mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } - return $obj; + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** @@ -221,7 +297,6 @@ public function listInvalidProperties() if ($this->container['warning_name'] === null) { $invalidProperties[] = "'warning_name' can't be null"; } - return $invalidProperties; } @@ -255,6 +330,9 @@ public function getWarningMsg() */ public function setWarningMsg(string $warning_msg) { + if (is_null($warning_msg)) { + throw new InvalidArgumentException('non-nullable warning_msg cannot be null'); + } $this->container['warning_msg'] = $warning_msg; return $this; @@ -279,6 +357,9 @@ public function getWarningName() */ public function setWarningName(string $warning_name) { + if (is_null($warning_name)) { + throw new InvalidArgumentException('non-nullable warning_name cannot be null'); + } $this->container['warning_name'] = $warning_name; return $this; @@ -287,12 +368,10 @@ public function setWarningName(string $warning_name) /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset - * - * @return bool + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -300,7 +379,7 @@ public function offsetExists($offset) /** * Gets offset. * - * @param mixed $offset Offset + * @param int $offset Offset * * @return mixed|null */ @@ -313,13 +392,11 @@ public function offsetGet($offset) /** * Sets value based on offset. * - * @param mixed $offset Offset - * @param mixed $value Value to be set - * - * @return void + * @param int|null $offset Offset + * @param mixed $value Value to be set */ #[ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -331,12 +408,10 @@ public function offsetSet($offset, $value) /** * Unsets offset. * - * @param mixed $offset Offset - * - * @return void + * @param int $offset Offset */ #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -345,8 +420,8 @@ public function offsetUnset($offset) * Serializes the object to a value that can be serialized natively by json_encode(). * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource */ #[ReturnTypeWillChange] public function jsonSerialize() diff --git a/sdks/php/src/ObjectSerializer.php b/sdks/php/src/ObjectSerializer.php index 1d8fba8a2..958cd8e04 100644 --- a/sdks/php/src/ObjectSerializer.php +++ b/sdks/php/src/ObjectSerializer.php @@ -5,7 +5,6 @@ * PHP version 7.4 * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ @@ -17,7 +16,7 @@ * The version of the OpenAPI document: 3.0.0 * Contact: apisupport@hellosign.com * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 5.3.0 + * Generator version: 7.8.0 */ /** @@ -29,26 +28,23 @@ namespace Dropbox\Sign; use DateTime; -use DateTimeInterface; use Dropbox\Sign\Model\ModelInterface; use Exception; -use GuzzleHttp\Psr7; -use GuzzleHttp\Utils; +use GuzzleHttp; +use GuzzleHttp\Psr7\Utils; use InvalidArgumentException; -use Psr\Http\Message; use SplFileObject; /** * ObjectSerializer Class Doc Comment * * @category Class - * @author OpenAPI Generator team * @see https://openapi-generator.tech */ class ObjectSerializer { /** @var string */ - private static $dateTimeFormat = DateTimeInterface::ATOM; + private static $dateTimeFormat = DateTime::ATOM; /** * Change the date format @@ -63,9 +59,9 @@ public static function setDateTimeFormat(string $format) /** * Serialize data * - * @param mixed $data the data to serialize - * @param string $type|null the OpenAPIToolsType of the data - * @param string $format|null the format of the OpenAPITools type of the data + * @param string|int|object|array|mixed $data the data to serialize + * @param string $type the OpenAPIToolsType of the data + * @param string $format the format of the OpenAPITools type of the data * * @return scalar|object|array|null serialized form of $data */ @@ -83,7 +79,6 @@ public static function sanitizeForSerialization($data, string $type = null, stri foreach ($data as $property => $value) { $data[$property] = self::sanitizeForSerialization($value); } - return $data; } @@ -93,15 +88,15 @@ public static function sanitizeForSerialization($data, string $type = null, stri $formats = $data::openAPIFormats(); foreach ($data::openAPITypes() as $property => $openAPIType) { $getter = $data::getters()[$property]; - $value = $data->$getter(); - if ($value !== null && !in_array($openAPIType, ['\DateTime', '\SplFileObject', 'array', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) { + $value = $data->{$getter}(); + if ($value !== null && !in_array($openAPIType, ['\DateTime', '\SplFileObject', 'array', 'bool', 'boolean', 'byte', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) { $callable = [$openAPIType, 'getAllowableEnumValues']; if (is_callable($callable)) { /** array $callable */ $allowedEnumTypes = $callable(); if (!in_array($value, $allowedEnumTypes, true)) { $imploded = implode("', '", $allowedEnumTypes); - throw new InvalidArgumentException("Invalid value for enum '$openAPIType', must be one of: '$imploded'"); + throw new InvalidArgumentException("Invalid value for enum '{$openAPIType}', must be one of: '{$imploded}'"); } } } @@ -110,17 +105,15 @@ public static function sanitizeForSerialization($data, string $type = null, stri } } } elseif ($data instanceof SplFileObject) { - return (string) $data; + return (string)$data; } else { foreach ($data as $property => $value) { $values[$property] = self::sanitizeForSerialization($value); } } - - return (object) $values; - } else { - return (string) $data; + return (object)$values; } + return (string)$data; } /** @@ -133,11 +126,10 @@ public static function sanitizeForSerialization($data, string $type = null, stri */ public static function sanitizeFilename(string $filename) { - if (preg_match("/.*[\/\\\\](.*)$/", $filename, $match)) { + if (preg_match('/.*[\\/\\\\](.*)$/', $filename, $match)) { return $match[1]; - } else { - return $filename; } + return $filename; } /** @@ -170,22 +162,143 @@ public static function toPathValue(string $value) } /** - * Take value and turn it into a string suitable for inclusion in - * the query, by imploding comma-separated if it's an object. - * If it's a string, pass through unchanged. It will be url-encoded - * later. + * Checks if a value is empty, based on its OpenAPI type. * - * @param string[]|string|DateTime $object an object to be serialized to a string + * @param string|int|object|array|mixed $value * - * @return string the serialized object + * @return bool true if $value is empty */ - public static function toQueryValue($object) + private static function isEmptyValue($value, string $openApiType): bool { - if (is_array($object)) { - return implode(',', $object); - } else { - return self::toString($object); + // If empty() returns false, it is not empty regardless of its type. + if (!empty($value)) { + return false; + } + + // Null is always empty, as we cannot send a real "null" value in a query parameter. + if ($value === null) { + return true; + } + + switch ($openApiType) { + // For numeric values, false and '' are considered empty. + // This comparison is safe for floating point values, since the previous call to empty() will + // filter out values that don't match 0. + case 'int': + case 'integer': + return $value !== 0; + + case 'number': + case 'float': + return $value !== 0 && $value !== 0.0; + + // For boolean values, '' is considered empty + case 'bool': + case 'boolean': + return !in_array($value, [false, 0], true); + + // For all the other types, any value at this point can be considered empty. + default: + return true; + } + } + + /** + * Take query parameter properties and turn it into an array suitable for + * native http_build_query or GuzzleHttp\Psr7\Query::build. + * + * @param string|int|object|array|mixed $value Parameter value + * @param string $paramName Parameter name + * @param string $openApiType OpenAPIType eg. array or object + * @param string $style Parameter serialization style + * @param bool $explode Parameter explode option + * @param bool $required Whether query param is required or not + */ + public static function toQueryValue( + $value, + string $paramName, + string $openApiType = 'string', + string $style = 'form', + bool $explode = true, + bool $required = true + ): array { + // Check if we should omit this parameter from the query. This should only happen when: + // - Parameter is NOT required; AND + // - its value is set to a value that is equivalent to "empty", depending on its OpenAPI type. For + // example, 0 as "int" or "boolean" is NOT an empty value. + if (self::isEmptyValue($value, $openApiType)) { + if ($required) { + return ["{$paramName}" => '']; + } + return []; + } + + // Handle DateTime objects in query + if ($openApiType === '\\DateTime' && $value instanceof DateTime) { + return ["{$paramName}" => $value->format(self::$dateTimeFormat)]; + } + + $query = []; + $value = (in_array($openApiType, ['object', 'array'], true)) ? (array)$value : $value; + + // since \GuzzleHttp\Psr7\Query::build fails with nested arrays + // need to flatten array first + $flattenArray = function ($arr, $name, &$result = []) use (&$flattenArray, $style, $explode) { + if (!is_array($arr)) { + return $arr; + } + + foreach ($arr as $k => $v) { + $prop = ($style === 'deepObject') ? $prop = "{$name}[{$k}]" : $k; + + if (is_array($v)) { + $flattenArray($v, $prop, $result); + } else { + if ($style !== 'deepObject' && !$explode) { + // push key itself + $result[] = $prop; + } + $result[$prop] = $v; + } + } + return $result; + }; + + $value = $flattenArray($value, $paramName); + + // https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-values + if ($openApiType === 'array' && $style === 'deepObject' && $explode) { + return $value; } + + if ($openApiType === 'object' && ($style === 'deepObject' || $explode)) { + return $value; + } + + if ('boolean' === $openApiType && is_bool($value)) { + $value = self::convertBoolToQueryStringFormat($value); + } + + // handle style in serializeCollection + $query[$paramName] = ($explode) ? $value : self::serializeCollection((array)$value, $style); + + return $query; + } + + /** + * Convert boolean value to format for query string. + * + * @param bool $value Boolean value + * + * @return int|string Boolean value in format + */ + public static function convertBoolToQueryStringFormat(bool $value) + { + if (Configuration::BOOLEAN_FORMAT_STRING == Configuration::getDefaultConfiguration()->getBooleanFormatForQueryString()) { + return $value ? 'true' : 'false'; + } + + return (int)$value; } /** @@ -220,9 +333,8 @@ public static function toFormValue($value) { if ($value instanceof SplFileObject) { return $value->getRealPath(); - } else { - return self::toString($value); } + return self::toString($value); } /** @@ -231,7 +343,7 @@ public static function toFormValue($value) * If it's a datetime object, format it in ISO8601 * If it's a boolean, convert it to "true" or "false". * - * @param string|bool|DateTime $value the value of the parameter + * @param string|int|object|array|mixed $value the value of the parameter * * @return string the header string */ @@ -239,20 +351,20 @@ public static function toString($value) { if ($value instanceof DateTime) { // datetime in ISO8601 format return $value->format(self::$dateTimeFormat); - } elseif (is_bool($value)) { + } + if (is_bool($value)) { return $value ? 'true' : 'false'; - } else { - return $value; } + return (string)$value; } /** * Serialize an array to a string. * - * @param array $collection collection to serialize to a string - * @param string $style the format use for serialization (csv, - * ssv, tsv, pipes, multi) - * @param bool $allowCollectionFormatMulti allow collection format to be a multidimensional array + * @param array $collection collection to serialize to a string + * @param string $style the format use for serialization (csv, + * ssv, tsv, pipes, multi) + * @param bool $allowCollectionFormatMulti allow collection format to be a multidimensional array * * @return string */ @@ -286,9 +398,9 @@ public static function serializeCollection(array $collection, string $style, boo /** * Deserialize a JSON string into an object * - * @param mixed $data object or primitive to be deserialized - * @param string $class class name is passed as a string - * @param string[] $httpHeaders HTTP headers + * @param string|int|object|array|mixed $data object or primitive to be deserialized + * @param string $class class name is passed as a string + * @param string[] $httpHeaders HTTP headers * * @return object|array|null a single or an array of $class instances */ @@ -299,10 +411,10 @@ public static function deserialize($data, string $class, array $httpHeaders = nu } if (strcasecmp(substr($class, -2), '[]') === 0) { - $data = is_string($data) ? json_decode($data, true) : $data; + $data = is_string($data) ? json_decode($data) : $data; if (!is_array($data)) { - throw new InvalidArgumentException("Invalid array '$class'"); + throw new InvalidArgumentException("Invalid array '{$class}'"); } $subClass = substr($class, 0, -2); @@ -310,12 +422,11 @@ public static function deserialize($data, string $class, array $httpHeaders = nu foreach ($data as $key => $value) { $values[$key] = self::deserialize($value, $subClass, null); } - return $values; } if (preg_match('/^(array<|map\[)/', $class)) { // for associative array e.g. array - $data = is_string($data) ? json_decode($data, true) : $data; + $data = is_string($data) ? json_decode($data) : $data; settype($data, 'array'); $inner = substr($class, 4, -1); $deserialized = []; @@ -326,22 +437,20 @@ public static function deserialize($data, string $class, array $httpHeaders = nu $deserialized[$key] = self::deserialize($value, $subClass, null); } } - return $deserialized; } if ($class === 'object') { settype($data, 'array'); - return $data; - } elseif ($class === 'mixed') { + } + if ($class === 'mixed') { settype($data, gettype($data)); - return $data; } - if ($class === 'DateTime') { - // Some API's return an invalid, empty string as a + if ($class === '\DateTime') { + // Some APIs return an invalid, empty string as a // date-time property. DateTime::__construct() will return // the current time for empty input which is probably not // what is meant. The invalid empty string is probably to @@ -351,7 +460,7 @@ public static function deserialize($data, string $class, array $httpHeaders = nu try { return new DateTime($data); } catch (Exception $exception) { - // Some API's return a date-time with too high nanosecond + // Some APIs return a date-time with too high nanosecond // precision for php's DateTime to handle. // With provided regexp 6 digits of microseconds saved return new DateTime(self::sanitizeTimestamp($data)); @@ -366,9 +475,9 @@ public static function deserialize($data, string $class, array $httpHeaders = nu return $data; } - $data = Psr7\Utils::streamFor($data); + $data = Utils::streamFor($data); - /* @var Message\StreamInterface $data */ + /** @var \Psr\Http\Message\StreamInterface $data */ // determine file name if ( @@ -390,92 +499,153 @@ public static function deserialize($data, string $class, array $httpHeaders = nu return new SplFileObject($filename, 'r'); } - /* @psalm-suppress ParadoxicalCondition */ - if (in_array($class, ['\DateTime', '\SplFileObject', 'array', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) { + /** @psalm-suppress ParadoxicalCondition */ + if (in_array($class, ['\DateTime', '\SplFileObject', 'array', 'bool', 'boolean', 'byte', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) { settype($data, $class); - - return $data; - } - - // handles unsupported union types like "bool|int|string" - if (!class_exists($class)) { return $data; } if (method_exists($class, 'getAllowableEnumValues')) { if (!in_array($data, $class::getAllowableEnumValues(), true)) { $imploded = implode("', '", $class::getAllowableEnumValues()); - throw new InvalidArgumentException("Invalid value for enum '$class', must be one of: '$imploded'"); + throw new InvalidArgumentException("Invalid value for enum '{$class}', must be one of: '{$imploded}'"); } - return $data; - } else { - $data = is_string($data) ? json_decode($data) : $data; - // If a discriminator is defined and points to a valid subclass, use it. - $discriminator = $class::DISCRIMINATOR; - - $discriminatorValue = null; - if (is_object($data)) { - $discriminatorValue = $data->{$discriminator} ?? null; - } elseif (is_array($data)) { - $discriminatorValue = $data[$discriminator] ?? null; + } + $data = is_string($data) ? json_decode($data) : $data; + + if (is_array($data)) { + $data = (object)$data; + } + + // If a discriminator is defined and points to a valid subclass, use it. + $discriminator = $class::DISCRIMINATOR; + $discriminatorValue = null; + if (is_object($data)) { + $discriminatorValue = $data->{$discriminator} ?? null; + } elseif (is_array($data)) { + $discriminatorValue = $data[$discriminator] ?? null; + } + + $discrimnatorSubclassFound = false; + if (!empty($discriminator) && isset($data->{$discriminator}) && is_string($data->{$discriminator})) { + $subclass = '\Dropbox\Sign\Model\\' . $data->{$discriminator}; + if (is_subclass_of($subclass, $class)) { + $class = $subclass; + $discrimnatorSubclassFound = true; } + } - $discrimnatorSubclassFound = false; - if (!empty($discriminator) && is_string($discriminatorValue)) { - $subclass = '\Dropbox\Sign\Model\\' . $discriminatorValue; - if (is_subclass_of($subclass, $class)) { - $class = $subclass; - $discrimnatorSubclassFound = true; - } + if ( + !$discrimnatorSubclassFound + && !empty($discriminator) + && method_exists($class, 'discriminatorClassName') + ) { + $subclass = call_user_func( + "{$class}::discriminatorClassName", + (array)$data, + ); + + if (empty($subclass)) { + return null; } - if ( - !$discrimnatorSubclassFound - && !empty($discriminator) - && method_exists($class, 'discriminatorClassName') - ) { - $subclass = call_user_func( - "{$class}::discriminatorClassName", - (array) $data, - ); + $class = $subclass; + $discrimnatorSubclassFound = true; + } + + /** @var ModelInterface $instance */ + $instance = new $class(); + foreach ($instance::openAPITypes() as $property => $type) { + $propertySetter = $instance::setters()[$property]; + + if (!isset($propertySetter)) { + continue; + } - if (empty($subclass)) { - return null; + if (!isset($data->{$instance::attributeMap()[$property]})) { + if ($instance::isNullable($property)) { + $instance->{$propertySetter}(null); } - $class = $subclass; - $discrimnatorSubclassFound = true; + continue; } - /** @var ModelInterface $instance */ - $instance = new $class(); - foreach ($instance::openAPITypes() as $property => $type) { - $propertySetter = $instance::setters()[$property]; + if (isset($data->{$instance::attributeMap()[$property]})) { + $propertyValue = $data->{$instance::attributeMap()[$property]}; + $instance->{$propertySetter}(self::deserialize($propertyValue, $type, null)); + } + } + return $instance; + } - if (!isset($propertySetter)) { - continue; - } + /** + * Build a query string from an array of key value pairs. + * + * This function can use the return value of `parse()` to build a query + * string. This function does not modify the provided keys when an array is + * encountered (like `http_build_query()` would). + * + * The function is copied from https://github.com/guzzle/psr7/blob/a243f80a1ca7fe8ceed4deee17f12c1930efe662/src/Query.php#L59-L112 + * with a modification which is described in https://github.com/guzzle/psr7/pull/603 + * + * @param array $params query string parameters + * @param int|false $encoding set to false to not encode, PHP_QUERY_RFC3986 + * to encode using RFC3986, or PHP_QUERY_RFC1738 + * to encode using RFC1738 + */ + public static function buildQuery(array $params, $encoding = PHP_QUERY_RFC3986): string + { + if (!$params) { + return ''; + } + + if ($encoding === false) { + $encoder = function (string $str): string { + return $str; + }; + } elseif ($encoding === PHP_QUERY_RFC3986) { + $encoder = 'rawurlencode'; + } elseif ($encoding === PHP_QUERY_RFC1738) { + $encoder = 'urlencode'; + } else { + throw new InvalidArgumentException('Invalid type'); + } - // Support object notation and array access - if (is_object($data) && isset($data->{$instance::attributeMap()[$property]})) { - $propertyValue = $data->{$instance::attributeMap()[$property]}; - $instance->$propertySetter(self::deserialize($propertyValue, $type, null)); - } elseif (is_array($data) && isset($data[$instance::attributeMap()[$property]])) { - $propertyValue = $data[$instance::attributeMap()[$property]]; - $instance->$propertySetter(self::deserialize($propertyValue, $type, null)); + $castBool = Configuration::BOOLEAN_FORMAT_INT == Configuration::getDefaultConfiguration()->getBooleanFormatForQueryString() + ? function ($v) { return (int)$v; } + : function ($v) { return $v ? 'true' : 'false'; }; + + $qs = ''; + foreach ($params as $k => $v) { + $k = $encoder((string)$k); + if (!is_array($v)) { + $qs .= $k; + $v = is_bool($v) ? $castBool($v) : $v; + if ($v !== null) { + $qs .= '=' . $encoder((string)$v); + } + $qs .= '&'; + } else { + foreach ($v as $vv) { + $qs .= $k; + $vv = is_bool($vv) ? $castBool($vv) : $vv; + if ($vv !== null) { + $qs .= '=' . $encoder((string)$vv); + } + $qs .= '&'; } } - - return $instance; } + + return $qs ? (string)substr($qs, 0, -1) : ''; } /** * Allows a multipart/form-data request to grab data from the typed * class created by OpenAPI. */ - public static function getFormParams(Model\ModelInterface $model): array + public static function getFormParams(ModelInterface $model): array { $apiTypes = $model::openAPITypes(); $formParams = []; @@ -513,7 +683,7 @@ public static function getFormParams(Model\ModelInterface $model): array $keyCount[$key]++; - $formParams[$true_key] = Psr7\Utils::tryFopen( + $formParams[$true_key] = Utils::tryFopen( ObjectSerializer::toFormValue($file), 'rb' ); @@ -522,7 +692,7 @@ public static function getFormParams(Model\ModelInterface $model): array continue; } - $formParams[$true_key] = Psr7\Utils::tryFopen( + $formParams[$true_key] = Utils::tryFopen( ObjectSerializer::toFormValue($value), 'rb' ); @@ -532,7 +702,7 @@ public static function getFormParams(Model\ModelInterface $model): array $formParams[$true_key] = is_scalar($value) ? ObjectSerializer::toFormValue($value) - : Utils::jsonEncode( + : GuzzleHttp\Utils::jsonEncode( ObjectSerializer::sanitizeForSerialization( $value ) diff --git a/sdks/php/templates/.php-cs-fixer.dist.php b/sdks/php/templates/.php-cs-fixer.dist.php new file mode 100644 index 000000000..a8ff32efd --- /dev/null +++ b/sdks/php/templates/.php-cs-fixer.dist.php @@ -0,0 +1,105 @@ +in(__DIR__) + ->exclude('vendor') + ->exclude('test') + ->exclude('tests') + ->exclude('bin') + ->exclude('docs') + ->exclude('examples') + ->exclude('templates') + ->exclude('test_fixtures') +; + +$config = new PhpCsFixer\Config(); +$config->setParallelConfig( + PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect() +); +return $config->setRules([ + '@PhpCsFixer' => true, + '@Symfony' => true, + '@DoctrineAnnotation' => true, + 'binary_operator_spaces' => [ + 'operators' => [ + '=>' => null, + ], + ], + 'blank_line_before_statement' => [ + 'statements' => [], + ], + 'blank_line_after_opening_tag' => false, + 'cast_spaces' => [ + 'space' => 'none', + ], + 'class_definition' => [ + 'inline_constructor_arguments' => false, + 'space_before_parenthesis' => true, + ], + 'concat_space' => [ + 'spacing' => 'one', + ], + 'nullable_type_declaration_for_default_null_value' => false, + 'declare_parentheses' => true, + 'echo_tag_syntax' => [ + 'format' => 'short', + 'shorten_simple_statements_only' => true, + ], + 'fully_qualified_strict_types' => true, + 'global_namespace_import' => true, + 'general_phpdoc_annotation_remove' => [ + 'annotations' => [ + 'author', 'package', 'subpackage', 'version', + ], + ], + 'increment_style' => false, + 'multiline_whitespace_before_semicolons' => [ + 'strategy' => 'no_multi_line', + ], + 'ordered_imports' => [ + 'imports_order' => [ + 'class', 'function', 'const', + ], + 'sort_algorithm' => 'alpha', + ], + 'no_superfluous_phpdoc_tags' => [ + 'allow_mixed' => true, + 'allow_unused_params' => true, + 'remove_inheritdoc' => true, + ], + 'phpdoc_align' => [ + 'tags' => [ + 'method', 'param', 'property', 'return', 'type', 'var', + ], + ], + 'phpdoc_line_span' => [ + 'property' => 'single', + ], + 'phpdoc_separation' => false, + 'phpdoc_summary' => false, + 'phpdoc_to_comment' => false, + 'phpdoc_to_param_type' => [ + 'scalar_types' => true, + 'union_types' => false, + ], + 'php_unit_internal_class' => false, + 'php_unit_test_class_requires_covers' => false, + 'single_line_throw' => false, + 'statement_indentation' => [ + 'stick_comment_to_next_continuous_control_statement' => false, + ], + 'visibility_required' => [ + 'elements' => ['method', 'property'], + ], + 'yoda_style' => false, + 'trailing_comma_in_multiline' => [ + 'after_heredoc' => true, + ], +]) + ->setFinder($finder) + ->setRiskyAllowed(true) +; diff --git a/sdks/php/templates/ApiException.mustache b/sdks/php/templates/ApiException.mustache index 847a6d57f..944d3c8a6 100644 --- a/sdks/php/templates/ApiException.mustache +++ b/sdks/php/templates/ApiException.mustache @@ -1,7 +1,7 @@ tempFolderPath = sys_get_temp_dir(); } + /** + * Sets API key + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * @param string $key API key or token + * + * @return $this + */ +{{^useCustomTemplateCode}} + public function setApiKey($apiKeyIdentifier, $key) +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} + protected function setApiKey($apiKeyIdentifier, $key) +{{/useCustomTemplateCode}} + { + $this->apiKeys[$apiKeyIdentifier] = $key; + return $this; + } + + /** + * Gets API key + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * + * @return null|string API key or token + */ +{{^useCustomTemplateCode}} + public function getApiKey($apiKeyIdentifier) +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} + protected function getApiKey($apiKeyIdentifier) +{{/useCustomTemplateCode}} + { + return isset($this->apiKeys[$apiKeyIdentifier]) ? $this->apiKeys[$apiKeyIdentifier] : null; + } + + /** + * Sets the prefix for API key (e.g. Bearer) + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * @param string $prefix API key prefix, e.g. Bearer + * + * @return $this + */ +{{^useCustomTemplateCode}} + public function setApiKeyPrefix($apiKeyIdentifier, $prefix) +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} + protected function setApiKeyPrefix($apiKeyIdentifier, $prefix) +{{/useCustomTemplateCode}} + { + $this->apiKeyPrefixes[$apiKeyIdentifier] = $prefix; + return $this; + } + + /** + * Gets API key prefix + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * + * @return null|string + */ +{{^useCustomTemplateCode}} + public function getApiKeyPrefix($apiKeyIdentifier) +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} + protected function getApiKeyPrefix($apiKeyIdentifier) +{{/useCustomTemplateCode}} + { + return isset($this->apiKeyPrefixes[$apiKeyIdentifier]) ? $this->apiKeyPrefixes[$apiKeyIdentifier] : null; + } + /** * Sets the access token for OAuth * * @param string $accessToken Token for OAuth * - * @return self + * @return $this */ public function setAccessToken($accessToken) { @@ -127,15 +230,44 @@ class Configuration } /** - * Sets the API key + * Sets boolean format for query string. + * + * @param string $booleanFormat Boolean format for query string + * + * @return $this + */ +{{^useCustomTemplateCode}} + public function setBooleanFormatForQueryString(string $booleanFormat) +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} + protected function setBooleanFormatForQueryString(string $booleanFormat) +{{/useCustomTemplateCode}} + { + $this->booleanFormatForQueryString = $booleanFormat; + + return $this; + } + + /** + * Gets boolean format for query string. + * + * @return string Boolean format for query string + */ + public function getBooleanFormatForQueryString(): string + { + return $this->booleanFormatForQueryString; + } + + /** + * Sets the username for HTTP basic authentication * - * @param string $key API key or token + * @param string $username Username for HTTP basic authentication * - * @return self + * @return $this */ - public function setUsername(string $key): self + public function setUsername($username) { - $this->username = $key; + $this->username = $username; return $this; } @@ -149,12 +281,45 @@ class Configuration return $this->username; } + /** + * Sets the password for HTTP basic authentication + * + * @param string $password Password for HTTP basic authentication + * + * @return $this + */ +{{^useCustomTemplateCode}} + public function setPassword($password) +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} + protected function setPassword($password) +{{/useCustomTemplateCode}} + { + $this->password = $password; + return $this; + } + + /** + * Gets the password for HTTP basic authentication + * + * @return string Password for HTTP basic authentication + */ +{{^useCustomTemplateCode}} + public function getPassword() +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} + protected function getPassword() +{{/useCustomTemplateCode}} + { + return $this->password; + } + /** * Sets the host * * @param string $host Host * - * @return self + * @return $this */ public function setHost($host) { @@ -177,8 +342,8 @@ class Configuration * * @param string $userAgent the user agent of the api client * - * @throws InvalidArgumentException - * @return self + * @throws \InvalidArgumentException + * @return $this */ public function setUserAgent($userAgent) { @@ -205,7 +370,7 @@ class Configuration * * @param bool $debug Debug flag * - * @return self + * @return $this */ public function setDebug($debug) { @@ -228,7 +393,7 @@ class Configuration * * @param string $debugFile Debug file * - * @return self + * @return $this */ public function setDebugFile($debugFile) { @@ -251,7 +416,7 @@ class Configuration * * @param string $tempFolderPath Temp folder path * - * @return self + * @return $this */ public function setTempFolderPath($tempFolderPath) { @@ -314,6 +479,36 @@ class Configuration return $report; } + /** + * Get API key (with prefix if set) + * + * @param string $apiKeyIdentifier name of apikey + * + * @return null|string API key with the prefix + */ +{{^useCustomTemplateCode}} + public function getApiKeyWithPrefix($apiKeyIdentifier) +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} + protected function getApiKeyWithPrefix($apiKeyIdentifier) +{{/useCustomTemplateCode}} + { + $prefix = $this->getApiKeyPrefix($apiKeyIdentifier); + $apiKey = $this->getApiKey($apiKeyIdentifier); + + if ($apiKey === null) { + return null; + } + + if ($prefix === null) { + $keyWithPrefix = $apiKey; + } else { + $keyWithPrefix = $prefix . ' ' . $apiKey; + } + + return $keyWithPrefix; + } + /** * Returns an array of host settings * @@ -353,35 +548,34 @@ class Configuration } /** - * Returns URL based on the index and variables - * - * @param int $index index of the host settings - * @param array|null $variables hash of variable and the corresponding value (optional) - * @return string URL based on host settings - */ - public function getHostFromSettings($index, $variables = null) + * Returns URL based on host settings, index and variables + * + * @param array $hostSettings array of host settings, generated from getHostSettings() or equivalent from the API clients + * @param int $hostIndex index of the host settings + * @param array|null $variables hash of variable and the corresponding value (optional) + * @return string URL based on host settings + */ + public static function getHostString(array $hostSettings, $hostIndex, array $variables = null) { if (null === $variables) { $variables = []; } - $hosts = $this->getHostSettings(); - // check array index out of bound - if ($index < 0 || $index >= sizeof($hosts)) { - throw new InvalidArgumentException("Invalid index $index when selecting the host. Must be less than ".sizeof($hosts)); + if ($hostIndex < 0 || $hostIndex >= count($hostSettings)) { + throw new \InvalidArgumentException("Invalid index $hostIndex when selecting the host. Must be less than ".count($hostSettings)); } - $host = $hosts[$index]; + $host = $hostSettings[$hostIndex]; $url = $host["url"]; // go through variable and assign a value foreach ($host["variables"] ?? [] as $name => $variable) { if (array_key_exists($name, $variables)) { // check to see if it's in the variables provided by the user - if (in_array($variables[$name], $variable["enum_values"], true)) { // check to see if the value is in the enum + if (!isset($variable['enum_values']) || in_array($variables[$name], $variable["enum_values"], true)) { // check to see if the value is in the enum $url = str_replace("{".$name."}", $variables[$name], $url); } else { - throw new InvalidArgumentException("The variable `$name` in the host URL has invalid value ".$variables[$name].". Must be ".join(',', $variable["enum_values"])."."); + throw new \InvalidArgumentException("The variable `$name` in the host URL has invalid value ".$variables[$name].". Must be ".join(',', $variable["enum_values"])."."); } } else { // use default value @@ -393,14 +587,22 @@ class Configuration } /** - * Set extra request options + * Returns URL based on the index and variables * - * @param array $options - * @return self + * @param int $index index of the host settings + * @param array|null $variables hash of variable and the corresponding value (optional) + * @return string URL based on host settings */ + public function getHostFromSettings($index, $variables = null) + { + return self::getHostString($this->getHostSettings(), $index, $variables); + } +{{#useCustomTemplateCode}} + public function setOptions(array $options): self { $this->options = $options; + return $this; } @@ -425,4 +627,5 @@ class Configuration { return $this->payloadHook; } +{{/useCustomTemplateCode}} } diff --git a/sdks/php/templates/HeaderSelector.mustache b/sdks/php/templates/HeaderSelector.mustache index 06f2a4a3f..1921b0610 100644 --- a/sdks/php/templates/HeaderSelector.mustache +++ b/sdks/php/templates/HeaderSelector.mustache @@ -1,7 +1,7 @@ selectContentTypeHeader($contentTypes); - return $headers; - } + if (!$isMultipart) { + if($contentType === '') { + $contentType = 'application/json'; + } - /** - * @param string[] $accept - * @return array - */ - public function selectHeadersForMultipart($accept) - { - $headers = $this->selectHeaders($accept, []); + $headers['Content-Type'] = $contentType; + } - unset($headers['Content-Type']); return $headers; } /** - * Return the header 'Accept' based on an array of Accept provided + * Return the header 'Accept' based on an array of Accept provided. * * @param string[] $accept Array of header * * @return null|string Accept (e.g. application/json) */ - private function selectAcceptHeader($accept) + private function selectAcceptHeader(array $accept): ?string { - if (count($accept) === 0 || (count($accept) === 1 && $accept[0] === '')) { + # filter out empty entries + $accept = array_filter($accept); + + if (count($accept) === 0) { return null; - } elseif ($jsonAccept = preg_grep('~(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$~', $accept)) { - return implode(',', $jsonAccept); - } else { + } + + # If there's only one Accept header, just use it + if (count($accept) === 1) { + return reset($accept); + } + + # If none of the available Accept headers is of type "json", then just use all them + $headersWithJson = preg_grep('~(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$~', $accept); + if (count($headersWithJson) === 0) { return implode(',', $accept); } + + # If we got here, then we need add quality values (weight), as described in IETF RFC 9110, Items 12.4.2/12.5.1, + # to give the highest priority to json-like headers - recalculating the existing ones, if needed + return $this->getAcceptHeaderWithAdjustedWeight($accept, $headersWithJson); } /** - * Return the content type based on an array of content-type provided + * Create an Accept header string from the given "Accept" headers array, recalculating all weights + * + * @param string[] $accept Array of Accept Headers + * @param string[] $headersWithJson Array of Accept Headers of type "json" + * + * @return string "Accept" Header (e.g. "application/json, text/html; q=0.9") + */ + private function getAcceptHeaderWithAdjustedWeight(array $accept, array $headersWithJson): string + { + $processedHeaders = [ + 'withApplicationJson' => [], + 'withJson' => [], + 'withoutJson' => [], + ]; + + foreach ($accept as $header) { + + $headerData = $this->getHeaderAndWeight($header); + + if (stripos($headerData['header'], 'application/json') === 0) { + $processedHeaders['withApplicationJson'][] = $headerData; + } elseif (in_array($header, $headersWithJson, true)) { + $processedHeaders['withJson'][] = $headerData; + } else { + $processedHeaders['withoutJson'][] = $headerData; + } + } + + $acceptHeaders = []; + $currentWeight = 1000; + + $hasMoreThan28Headers = count($accept) > 28; + + foreach($processedHeaders as $headers) { + if (count($headers) > 0) { + $acceptHeaders[] = $this->adjustWeight($headers, $currentWeight, $hasMoreThan28Headers); + } + } + + $acceptHeaders = array_merge(...$acceptHeaders); + + return implode(',', $acceptHeaders); + } + + /** + * Given an Accept header, returns an associative array splitting the header and its weight * - * @param string[] $contentType Array fo content-type + * @param string $header "Accept" Header * - * @return string Content-Type (e.g. application/json) + * @return array with the header and its weight */ - private function selectContentTypeHeader($contentType) + private function getHeaderAndWeight(string $header): array { - if (count($contentType) === 0 || (count($contentType) === 1 && $contentType[0] === '')) { - return 'application/json'; - } elseif (preg_grep("/application\/json/i", $contentType)) { - return 'application/json'; + # matches headers with weight, splitting the header and the weight in $outputArray + if (preg_match('/(.*);\s*q=(1(?:\.0+)?|0\.\d+)$/', $header, $outputArray) === 1) { + $headerData = [ + 'header' => $outputArray[1], + 'weight' => (int)($outputArray[2] * 1000), + ]; } else { - return implode(',', $contentType); + $headerData = [ + 'header' => trim($header), + 'weight' => 1000, + ]; } + + return $headerData; + } + + /** + * @param array[] $headers + * @param float $currentWeight + * @param bool $hasMoreThan28Headers + * @return string[] array of adjusted "Accept" headers + */ + private function adjustWeight(array $headers, float &$currentWeight, bool $hasMoreThan28Headers): array + { + usort($headers, function (array $a, array $b) { + return $b['weight'] - $a['weight']; + }); + + $acceptHeaders = []; + foreach ($headers as $index => $header) { + if($index > 0 && $headers[$index - 1]['weight'] > $header['weight']) + { + $currentWeight = $this->getNextWeight($currentWeight, $hasMoreThan28Headers); + } + + $weight = $currentWeight; + + $acceptHeaders[] = $this->buildAcceptHeader($header['header'], $weight); + } + + $currentWeight = $this->getNextWeight($currentWeight, $hasMoreThan28Headers); + + return $acceptHeaders; + } + + /** + * @param string $header + * @param int $weight + * @return string + */ + private function buildAcceptHeader(string $header, int $weight): string + { + if($weight === 1000) { + return $header; + } + + return trim($header, '; ') . ';q=' . rtrim(sprintf('%0.3f', $weight / 1000), '0'); + } + + /** + * Calculate the next weight, based on the current one. + * + * If there are less than 28 "Accept" headers, the weights will be decreased by 1 on its highest significant digit, using the + * following formula: + * + * next weight = current weight - 10 ^ (floor(log(current weight - 1))) + * + * ( current weight minus ( 10 raised to the power of ( floor of (log to the base 10 of ( current weight minus 1 ) ) ) ) ) + * + * Starting from 1000, this generates the following series: + * + * 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 + * + * The resulting quality codes are closer to the average "normal" usage of them (like "q=0.9", "q=0.8" and so on), but it only works + * if there is a maximum of 28 "Accept" headers. If we have more than that (which is extremely unlikely), then we fall back to a 1-by-1 + * decrement rule, which will result in quality codes like "q=0.999", "q=0.998" etc. + * + * @param int $currentWeight varying from 1 to 1000 (will be divided by 1000 to build the quality value) + * @param bool $hasMoreThan28Headers + * @return int + */ + public function getNextWeight(int $currentWeight, bool $hasMoreThan28Headers): int + { + if ($currentWeight <= 1) { + return 1; + } + + if ($hasMoreThan28Headers) { + return $currentWeight - 1; + } + + return $currentWeight - 10 ** floor( log10($currentWeight - 1) ); } } diff --git a/sdks/php/templates/ModelInterface.mustache b/sdks/php/templates/ModelInterface.mustache index f37dd32ad..805db43f0 100644 --- a/sdks/php/templates/ModelInterface.mustache +++ b/sdks/php/templates/ModelInterface.mustache @@ -2,7 +2,7 @@ /** * ModelInterface * - * PHP version {{phpVersion}} + * PHP version 7.4 * * @category Class * @package {{modelPackage}} @@ -83,4 +83,20 @@ interface ModelInterface * @return bool */ public function valid(); + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool; + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool; } diff --git a/sdks/php/templates/ObjectSerializer.mustache b/sdks/php/templates/ObjectSerializer.mustache index 636d517b1..281ed61db 100644 --- a/sdks/php/templates/ObjectSerializer.mustache +++ b/sdks/php/templates/ObjectSerializer.mustache @@ -2,7 +2,7 @@ /** * ObjectSerializer * - * PHP version {{phpVersion}} + * PHP version 7.4 * * @category Class * @package {{invokerPackage}} @@ -19,14 +19,11 @@ namespace {{invokerPackage}}; +use GuzzleHttp\Psr7\Utils; use {{modelPackage}}\ModelInterface; -use Psr\Http\Message; -use DateTime; -use DateTimeInterface; -use InvalidArgumentException; -use SplFileObject; -use GuzzleHttp\Psr7; -use GuzzleHttp\Utils; +{{#useCustomTemplateCode}} +use GuzzleHttp; +{{/useCustomTemplateCode}} /** * ObjectSerializer Class Doc Comment @@ -39,7 +36,7 @@ use GuzzleHttp\Utils; class ObjectSerializer { /** @var string */ - private static $dateTimeFormat = DateTimeInterface::ATOM; + private static $dateTimeFormat = \DateTime::ATOM; /** * Change the date format @@ -54,13 +51,18 @@ class ObjectSerializer /** * Serialize data * +{{^useCustomTemplateCode}} * @param mixed $data the data to serialize - * @param string $type|null the OpenAPIToolsType of the data - * @param string $format|null the format of the OpenAPITools type of the data +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} + * @param string|int|object|array|mixed $data the data to serialize +{{/useCustomTemplateCode}} + * @param string $type the OpenAPIToolsType of the data + * @param string $format the format of the OpenAPITools type of the data * * @return scalar|object|array|null serialized form of $data */ - public static function sanitizeForSerialization($data, string $type = null, string $format = null) + public static function sanitizeForSerialization($data, $type = null, $format = null) { if (is_scalar($data) || null === $data) { return $data; @@ -95,12 +97,19 @@ class ObjectSerializer } } } +{{^useCustomTemplateCode}} + if (($data::isNullable($property) && $data->isNullableSetToNull($property)) || $value !== null) { +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} if ($value !== null) { +{{/useCustomTemplateCode}} $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $openAPIType, $formats[$property]); } } - } else if ($data instanceof SplFileObject) { +{{#useCustomTemplateCode}} + } else if ($data instanceof \SplFileObject) { return (string) $data; +{{/useCustomTemplateCode}} } else { foreach($data as $property => $value) { $values[$property] = self::sanitizeForSerialization($value); @@ -157,22 +166,156 @@ class ObjectSerializer } /** - * Take value and turn it into a string suitable for inclusion in - * the query, by imploding comma-separated if it's an object. - * If it's a string, pass through unchanged. It will be url-encoded - * later. + * Checks if a value is empty, based on its OpenAPI type. * - * @param string[]|string|\DateTime $object an object to be serialized to a string +{{^useCustomTemplateCode}} + * @param mixed $value +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} + * @param string|int|object|array|mixed $value +{{/useCustomTemplateCode}} + * @param string $openApiType * - * @return string the serialized object + * @return bool true if $value is empty */ - public static function toQueryValue($object) + private static function isEmptyValue($value, string $openApiType): bool { - if (is_array($object)) { - return implode(',', $object); - } else { - return self::toString($object); + # If empty() returns false, it is not empty regardless of its type. + if (!empty($value)) { + return false; + } + + # Null is always empty, as we cannot send a real "null" value in a query parameter. + if ($value === null) { + return true; + } + + switch ($openApiType) { + # For numeric values, false and '' are considered empty. + # This comparison is safe for floating point values, since the previous call to empty() will + # filter out values that don't match 0. + case 'int': + case 'integer': + return $value !== 0; + + case 'number': + case 'float': + return $value !== 0 && $value !== 0.0; + + # For boolean values, '' is considered empty + case 'bool': + case 'boolean': + return !in_array($value, [false, 0], true); + + # For all the other types, any value at this point can be considered empty. + default: + return true; + } + } + + /** + * Take query parameter properties and turn it into an array suitable for + * native http_build_query or GuzzleHttp\Psr7\Query::build. + * +{{^useCustomTemplateCode}} + * @param mixed $value Parameter value +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} + * @param string|int|object|array|mixed $value Parameter value +{{/useCustomTemplateCode}} + * @param string $paramName Parameter name + * @param string $openApiType OpenAPIType eg. array or object + * @param string $style Parameter serialization style + * @param bool $explode Parameter explode option + * @param bool $required Whether query param is required or not + * + * @return array + */ + public static function toQueryValue( + $value, + string $paramName, + string $openApiType = 'string', + string $style = 'form', + bool $explode = true, + bool $required = true + ): array { + + # Check if we should omit this parameter from the query. This should only happen when: + # - Parameter is NOT required; AND + # - its value is set to a value that is equivalent to "empty", depending on its OpenAPI type. For + # example, 0 as "int" or "boolean" is NOT an empty value. + if (self::isEmptyValue($value, $openApiType)) { + if ($required) { + return ["{$paramName}" => '']; + } else { + return []; + } + } + + # Handle DateTime objects in query + if($openApiType === "\\DateTime" && $value instanceof \DateTime) { + return ["{$paramName}" => $value->format(self::$dateTimeFormat)]; + } + + $query = []; + $value = (in_array($openApiType, ['object', 'array'], true)) ? (array)$value : $value; + + // since \GuzzleHttp\Psr7\Query::build fails with nested arrays + // need to flatten array first + $flattenArray = function ($arr, $name, &$result = []) use (&$flattenArray, $style, $explode) { + if (!is_array($arr)) return $arr; + + foreach ($arr as $k => $v) { + $prop = ($style === 'deepObject') ? $prop = "{$name}[{$k}]" : $k; + + if (is_array($v)) { + $flattenArray($v, $prop, $result); + } else { + if ($style !== 'deepObject' && !$explode) { + // push key itself + $result[] = $prop; + } + $result[$prop] = $v; + } + } + return $result; + }; + + $value = $flattenArray($value, $paramName); + + // https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-values + if ($openApiType === 'array' && $style === 'deepObject' && $explode) { + return $value; + } + + if ($openApiType === 'object' && ($style === 'deepObject' || $explode)) { + return $value; + } + + if ('boolean' === $openApiType && is_bool($value)) { + $value = self::convertBoolToQueryStringFormat($value); + } + + // handle style in serializeCollection + $query[$paramName] = ($explode) ? $value : self::serializeCollection((array)$value, $style); + + return $query; + } + + /** + * Convert boolean value to format for query string. + * + * @param bool $value Boolean value + * + * @return int|string Boolean value in format + */ + public static function convertBoolToQueryStringFormat(bool $value) + { + if (Configuration::BOOLEAN_FORMAT_STRING == Configuration::getDefaultConfiguration()->getBooleanFormatForQueryString()) { + return $value ? 'true' : 'false'; } + + return (int) $value; } /** @@ -218,7 +361,12 @@ class ObjectSerializer * If it's a datetime object, format it in ISO8601 * If it's a boolean, convert it to "true" or "false". * - * @param string|bool|DateTime $value the value of the parameter +{{^useCustomTemplateCode}} + * @param float|int|bool|\DateTime $value the value of the parameter +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} + * @param string|int|object|array|mixed $value the value of the parameter +{{/useCustomTemplateCode}} * * @return string the header string */ @@ -229,7 +377,7 @@ class ObjectSerializer } elseif (is_bool($value)) { return $value ? 'true' : 'false'; } else { - return $value; + return (string) $value; } } @@ -273,7 +421,12 @@ class ObjectSerializer /** * Deserialize a JSON string into an object * +{{^useCustomTemplateCode}} * @param mixed $data object or primitive to be deserialized +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} + * @param string|int|object|array|mixed $data object or primitive to be deserialized +{{/useCustomTemplateCode}} * @param string $class class name is passed as a string * @param string[] $httpHeaders HTTP headers * @@ -286,7 +439,7 @@ class ObjectSerializer } if (strcasecmp(substr($class, -2), '[]') === 0) { - $data = is_string($data) ? json_decode($data, true) : $data; + $data = is_string($data) ? json_decode($data) : $data; if (!is_array($data)) { throw new \InvalidArgumentException("Invalid array '$class'"); @@ -295,13 +448,18 @@ class ObjectSerializer $subClass = substr($class, 0, -2); $values = []; foreach ($data as $key => $value) { +{{^useCustomTemplateCode}} + $values[] = self::deserialize($value, $subClass, null); +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} $values[$key] = self::deserialize($value, $subClass, null); +{{/useCustomTemplateCode}} } return $values; } if (preg_match('/^(array<|map\[)/', $class)) { // for associative array e.g. array - $data = is_string($data) ? json_decode($data, true) : $data; + $data = is_string($data) ? json_decode($data) : $data; settype($data, 'array'); $inner = substr($class, 4, -1); $deserialized = []; @@ -318,13 +476,13 @@ class ObjectSerializer if ($class === 'object') { settype($data, 'array'); return $data; - } else if ($class === 'mixed') { + } elseif ($class === 'mixed') { settype($data, gettype($data)); return $data; } - if ($class === 'DateTime') { - // Some API's return an invalid, empty string as a + if ($class === '\DateTime') { + // Some APIs return an invalid, empty string as a // date-time property. DateTime::__construct() will return // the current time for empty input which is probably not // what is meant. The invalid empty string is probably to @@ -334,7 +492,7 @@ class ObjectSerializer try { return new \DateTime($data); } catch (\Exception $exception) { - // Some API's return a date-time with too high nanosecond + // Some APIs return a date-time with too high nanosecond // precision for php's DateTime to handle. // With provided regexp 6 digits of microseconds saved return new \DateTime(self::sanitizeTimestamp($data)); @@ -345,13 +503,15 @@ class ObjectSerializer } if ($class === '\SplFileObject') { - if (is_a($data, SplFileObject::class)) { +{{#useCustomTemplateCode}} + if (is_a($data, \SplFileObject::class)) { return $data; } - $data = Psr7\Utils::streamFor($data); +{{/useCustomTemplateCode}} + $data = Utils::streamFor($data); - /** @var Message\StreamInterface $data */ + /** @var \Psr\Http\Message\StreamInterface $data */ // determine file name if ( @@ -379,11 +539,6 @@ class ObjectSerializer return $data; } - // handles unsupported union types like "bool|int|string" - if (!class_exists($class)) { - return $data; - } - if (method_exists($class, 'getAllowableEnumValues')) { if (!in_array($data, $class::getAllowableEnumValues(), true)) { @@ -393,9 +548,14 @@ class ObjectSerializer return $data; } else { $data = is_string($data) ? json_decode($data) : $data; + + if (is_array($data)) { + $data = (object)$data; + } + // If a discriminator is defined and points to a valid subclass, use it. $discriminator = $class::DISCRIMINATOR; - +{{#useCustomTemplateCode}} $discriminatorValue = null; if (is_object($data)) { $discriminatorValue = $data->{$discriminator} ?? null; @@ -404,13 +564,17 @@ class ObjectSerializer } $discrimnatorSubclassFound = false; - if (!empty($discriminator) && is_string($discriminatorValue)) { - $subclass = '\Dropbox\Sign\Model\\' . $discriminatorValue; +{{/useCustomTemplateCode}} + if (!empty($discriminator) && isset($data->{$discriminator}) && is_string($data->{$discriminator})) { + $subclass = '\{{invokerPackage}}\Model\\' . $data->{$discriminator}; if (is_subclass_of($subclass, $class)) { $class = $subclass; +{{#useCustomTemplateCode}} $discrimnatorSubclassFound = true; +{{/useCustomTemplateCode}} } } +{{#useCustomTemplateCode}} if ( !$discrimnatorSubclassFound @@ -429,6 +593,7 @@ class ObjectSerializer $class = $subclass; $discrimnatorSubclassFound = true; } +{{/useCustomTemplateCode}} /** @var ModelInterface $instance */ $instance = new $class(); @@ -439,24 +604,91 @@ class ObjectSerializer continue; } - // Support object notation and array access - if (is_object($data) && isset($data->{$instance::attributeMap()[$property]})) { + if (!isset($data->{$instance::attributeMap()[$property]})) { + if ($instance::isNullable($property)) { + $instance->$propertySetter(null); + } + + continue; + } + + if (isset($data->{$instance::attributeMap()[$property]})) { $propertyValue = $data->{$instance::attributeMap()[$property]}; $instance->$propertySetter(self::deserialize($propertyValue, $type, null)); - } elseif (is_array($data) && isset($data[$instance::attributeMap()[$property]])) { - $propertyValue = $data[$instance::attributeMap()[$property]]; - $instance->$propertySetter(self::deserialize($propertyValue, $type, null)); } } return $instance; } } + /** + * Build a query string from an array of key value pairs. + * + * This function can use the return value of `parse()` to build a query + * string. This function does not modify the provided keys when an array is + * encountered (like `http_build_query()` would). + * + * The function is copied from https://github.com/guzzle/psr7/blob/a243f80a1ca7fe8ceed4deee17f12c1930efe662/src/Query.php#L59-L112 + * with a modification which is described in https://github.com/guzzle/psr7/pull/603 + * + * @param array $params Query string parameters. + * @param int|false $encoding Set to false to not encode, PHP_QUERY_RFC3986 + * to encode using RFC3986, or PHP_QUERY_RFC1738 + * to encode using RFC1738. + */ + public static function buildQuery(array $params, $encoding = PHP_QUERY_RFC3986): string + { + if (!$params) { + return ''; + } + + if ($encoding === false) { + $encoder = function (string $str): string { + return $str; + }; + } elseif ($encoding === PHP_QUERY_RFC3986) { + $encoder = 'rawurlencode'; + } elseif ($encoding === PHP_QUERY_RFC1738) { + $encoder = 'urlencode'; + } else { + throw new \InvalidArgumentException('Invalid type'); + } + + $castBool = Configuration::BOOLEAN_FORMAT_INT == Configuration::getDefaultConfiguration()->getBooleanFormatForQueryString() + ? function ($v) { return (int) $v; } + : function ($v) { return $v ? 'true' : 'false'; }; + + $qs = ''; + foreach ($params as $k => $v) { + $k = $encoder((string) $k); + if (!is_array($v)) { + $qs .= $k; + $v = is_bool($v) ? $castBool($v) : $v; + if ($v !== null) { + $qs .= '='.$encoder((string) $v); + } + $qs .= '&'; + } else { + foreach ($v as $vv) { + $qs .= $k; + $vv = is_bool($vv) ? $castBool($vv) : $vv; + if ($vv !== null) { + $qs .= '='.$encoder((string) $vv); + } + $qs .= '&'; + } + } + } + + return $qs ? (string) substr($qs, 0, -1) : ''; + } +{{#useCustomTemplateCode}} + /** * Allows a multipart/form-data request to grab data from the typed * class created by OpenAPI. */ - public static function getFormParams(Model\ModelInterface $model): array + public static function getFormParams(ModelInterface $model): array { $apiTypes = $model::openAPITypes(); $formParams = []; @@ -494,7 +726,7 @@ class ObjectSerializer $keyCount[$key]++; - $formParams[$true_key] = Psr7\Utils::tryFopen( + $formParams[$true_key] = Utils::tryFopen( ObjectSerializer::toFormValue($file), 'rb' ); @@ -503,7 +735,7 @@ class ObjectSerializer continue; } - $formParams[$true_key] = Psr7\Utils::tryFopen( + $formParams[$true_key] = Utils::tryFopen( ObjectSerializer::toFormValue($value), 'rb' ); @@ -513,7 +745,7 @@ class ObjectSerializer $formParams[$true_key] = is_scalar($value) ? ObjectSerializer::toFormValue($value) - : Utils::jsonEncode( + : GuzzleHttp\Utils::jsonEncode( ObjectSerializer::sanitizeForSerialization( $value ) @@ -522,4 +754,5 @@ class ObjectSerializer return $hasFile ? $formParams : []; } +{{/useCustomTemplateCode}} } diff --git a/sdks/php/templates/README.mustache b/sdks/php/templates/README.mustache index a22941039..a0f14993d 100644 --- a/sdks/php/templates/README.mustache +++ b/sdks/php/templates/README.mustache @@ -8,6 +8,7 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}). {{/infoUrl}} +{{#useCustomTemplateCode}} ## Migrating from legacy SDK This SDK is generated from our officially maintained [OpenAPI spec](https://github.com/hellosign/hellosign-openapi/blob/main/openapi.yaml). @@ -45,37 +46,97 @@ Run the following and everything is done for you: to the OAS file and/or the mustache template files _will be lost_ when you run this command. +{{/useCustomTemplateCode}} ## Installation & Usage ### Requirements +{{^useCustomTemplateCode}} +PHP 7.4 and later. +Should also work with PHP 8.0. +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} PHP {{phpVersion}} and later. +{{/useCustomTemplateCode}} ### Composer To install the bindings via [Composer](https://getcomposer.org/), add the following to `composer.json`: ```json +{{^useCustomTemplateCode}} +{ + "repositories": [ + { + "type": "vcs", + "url": "https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}.git" + } + ], + "require": { + "{{gitUserId}}/{{gitRepoId}}": "*@dev" + } +} +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} { "require": { "{{packageName}}": "{{packageVersion}}" }, "minimum-stability": "dev" } +{{/useCustomTemplateCode}} ``` -Then run `composer install`. +Then run `composer install` + +{{^useCustomTemplateCode}} +### Manual Installation +Download the files and include `autoload.php`: + +```php + php_doc_auth_partial}} +$apiInstance = new {{invokerPackage}}\Api\{{classname}}( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(){{#hasAuthMethods}}, + $config{{/hasAuthMethods}} +); +{{#allParams}}${{paramName}} = {{{example}}}; // {{{dataType}}}{{#description}} | {{{.}}}{{/description}} +{{/allParams}} + +try { + {{#returnType}}$result = {{/returnType}}$apiInstance->{{{operationId}}}({{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}});{{#returnType}} + print_r($result);{{/returnType}} +} catch (Exception $e) { + echo 'Exception when calling {{classname}}->{{operationId}}: ', $e->getMessage(), PHP_EOL; +} +{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} +``` +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} {{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} ```php REPLACE_ME_WITH_EXAMPLE_FOR__{{{operationId}}}_PHP_CODE @@ -120,26 +181,42 @@ try { . $e->getMessage() . PHP_EOL; } ``` +{{/useCustomTemplateCode}} ## API Endpoints All URIs are relative to *{{basePath}}* +{{^useCustomTemplateCode}} +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}/{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{summary}} +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} | Class | Method | HTTP request | Description | | ---------- | ------------- | ------------- | ------------- | {{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}| *{{classname}}* | [**{{operationId}}**]({{apiDocPath}}/{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{summary}} | {{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + +{{/useCustomTemplateCode}} ## Models {{#models}}{{#model}}- [{{{classname}}}]({{modelDocPath}}/{{{classname}}}.md){{/model}} {{/models}} ## Authorization -{{^authMethods}} -All endpoints do not require authorization. -{{/authMethods}} +{{^useCustomTemplateCode}} +{{^authMethods}}Endpoints do not require authorization.{{/authMethods}} +{{#hasAuthMethods}}Authentication schemes defined for the API:{{/hasAuthMethods}} +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} +{{^authMethods}}All endpoints do not require authorization.{{/authMethods}} +{{/useCustomTemplateCode}} {{#authMethods}} +{{#useCustomTemplateCode}} {{#last}} Authentication schemes defined for the API:{{/last}} +{{/useCustomTemplateCode}} ### {{{name}}} {{#isApiKey}} @@ -157,6 +234,12 @@ All endpoints do not require authorization. - **Type**: Bearer authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} {{/isBasicBearer}} +{{^useCustomTemplateCode}} +{{#isHttpSignature}} + +- **Type**: HTTP signature authentication +{{/isHttpSignature}} +{{/useCustomTemplateCode}} {{/isBasic}} {{#isOAuth}} @@ -194,4 +277,5 @@ This PHP package is automatically generated by the [OpenAPI Generator](https://o {{^hideGenerationTimestamp}} - Build date: `{{generatedDate}}` {{/hideGenerationTimestamp}} + - Generator version: `{{generatorVersion}}` - Build package: `{{generatorClass}}` diff --git a/sdks/php/templates/api.mustache b/sdks/php/templates/api.mustache index 15568f55d..927ce19e3 100644 --- a/sdks/php/templates/api.mustache +++ b/sdks/php/templates/api.mustache @@ -1,7 +1,7 @@ [{{#consumes}} + '{{{mediaType}}}',{{/consumes}} + {{^consumes}} + 'application/json', +{{/consumes}} ],{{/operation}} + ]; + +{{#useCustomTemplateCode}} + /** @var ResponseInterface|null */ protected $response; +{{/useCustomTemplateCode}} +{{^useCustomTemplateCode}} + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} /** - * @param Configuration|null $config - * @param ClientInterface|null $client - * @param HeaderSelector|null $selector - * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + * @param Configuration $config + * @param ClientInterface $client + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( Configuration $config = null, @@ -82,6 +105,7 @@ use {{invokerPackage}}\ObjectSerializer; HeaderSelector $selector = null, $hostIndex = 0 ) { +{{/useCustomTemplateCode}} $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); $this->headerSelector = $selector ?: new HeaderSelector(); @@ -92,6 +116,9 @@ use {{invokerPackage}}\ObjectSerializer; * Set the host index * * @param int $hostIndex Host index (required) +{{#useCustomTemplateCode}} + * @deprecated To be made private in the future +{{/useCustomTemplateCode}} */ public function setHostIndex($hostIndex): void { @@ -102,6 +129,9 @@ use {{invokerPackage}}\ObjectSerializer; * Get the host index * * @return int Host index +{{#useCustomTemplateCode}} + * @deprecated To be made private in the future +{{/useCustomTemplateCode}} */ public function getHostIndex() { @@ -116,6 +146,7 @@ use {{invokerPackage}}\ObjectSerializer; return $this->config; } +{{#useCustomTemplateCode}} /** * @return ResponseInterface|null */ @@ -124,6 +155,7 @@ use {{invokerPackage}}\ObjectSerializer; return $this->response; } +{{/useCustomTemplateCode}} {{#operation}} /** * Operation {{{operationId}}} @@ -142,9 +174,20 @@ use {{invokerPackage}}\ObjectSerializer; {{/vendorExtensions.x-group-parameters}} {{#servers}} {{#-first}} - * This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. + * if needed, use the 'variables' parameter to pass variables to the host. {{/-first}} * URL: {{{url}}} +{{#variables}} +{{#-first}} + * Variables: +{{/-first}} + * - {{{name}}}: {{{description}}}{{^description}} No description provided{{/description}}{{#enumValues}} +{{#-first}} + * Allowed values: +{{/-first}} + * - {{{.}}}{{/enumValues}} +{{/variables}} {{#-last}} * {{/-last}} @@ -152,18 +195,35 @@ use {{invokerPackage}}\ObjectSerializer; {{#allParams}} * @param {{{dataType}}} ${{paramName}}{{#description}} {{.}}{{/description}}{{^description}} {{paramName}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}} {{/allParams}} +{{^useCustomTemplateCode}} +{{#servers}} +{{#-first}} + * @param null|int $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead + * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. +{{/-first}} +{{/servers}} + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['{{{operationId}}}'] to see the possible values for this operation +{{/useCustomTemplateCode}} * - * @throws \{{invokerPackage}}\ApiException on non-2xx response - * @throws InvalidArgumentException + * @throws \{{invokerPackage}}\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException * @return {{#returnType}}{{#responses}}{{#dataType}}{{^-first}}|{{/-first}}{{/dataType}}{{{dataType}}}{{/responses}}{{/returnType}}{{^returnType}}void{{/returnType}} {{#isDeprecated}} * @deprecated {{/isDeprecated}} */ +{{^useCustomTemplateCode}} + public function {{operationId}}({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}, {{/allParams}}{{#servers}}{{#-first}}?int $hostIndex = null, array $variables = [], {{/-first}}{{/servers}}string $contentType = self::contentTypes['{{{operationId}}}'][0]{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) + { + {{#returnType}}list($response) = {{/returnType}}$this->{{operationId}}WithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}, {{/allParams}}{{#servers}}{{#-first}}$hostIndex, $variables, {{/-first}}{{/servers}}$contentType{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}});{{#returnType}} + return $response;{{/returnType}} +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} public function {{operationId}}({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{{defaultValue}}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) { - {{#returnType}}list($response) = {{/returnType}}$this->{{operationId}}WithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}});{{#returnType}} + {{#returnType}}list($response) = {{/returnType}}$this->{{operationId}}WithHttpInfo({{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}});{{#returnType}} return $response;{{/returnType}} +{{/useCustomTemplateCode}} } /** @@ -183,9 +243,20 @@ use {{invokerPackage}}\ObjectSerializer; {{/vendorExtensions.x-group-parameters}} {{#servers}} {{#-first}} - * This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. + * if needed, use the 'variables' parameter to pass variables to the host. {{/-first}} * URL: {{{url}}} +{{#variables}} +{{#-first}} + * Variables: +{{/-first}} + * - {{{name}}}: {{{description}}}{{^description}} No description provided{{/description}}{{#enumValues}} +{{#-first}} + * Allowed values: +{{/-first}} + * - {{{.}}}{{/enumValues}} +{{/variables}} {{#-last}} * {{/-last}} @@ -193,23 +264,35 @@ use {{invokerPackage}}\ObjectSerializer; {{#allParams}} * @param {{{dataType}}} ${{paramName}}{{#description}} {{.}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}} {{/allParams}} +{{#servers}} +{{#-first}} + * @param null|int $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead + * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. +{{/-first}} +{{/servers}} + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['{{{operationId}}}'] to see the possible values for this operation * - * @throws \{{invokerPackage}}\ApiException on non-2xx response - * @throws InvalidArgumentException + * @throws \{{invokerPackage}}\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException * @return array of {{#returnType}}{{#responses}}{{#dataType}}{{^-first}}|{{/-first}}{{/dataType}}{{{dataType}}}{{/responses}}{{/returnType}}{{^returnType}}null{{/returnType}}, HTTP status code, HTTP response headers (array of strings) +{{#useCustomTemplateCode}} + * @deprecated Prefer to use ::{{operationId}}. This method will eventually become unavailable +{{/useCustomTemplateCode}} {{#isDeprecated}} * @deprecated {{/isDeprecated}} */ - public function {{operationId}}WithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{{defaultValue}}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) + public function {{operationId}}WithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}, {{/allParams}}{{#servers}}{{#-first}}?int $hostIndex = null, array $variables = [], {{/-first}}{{/servers}}string $contentType = self::contentTypes['{{{operationId}}}'][0]{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) { - $request = $this->{{operationId}}Request({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}); + $request = $this->{{operationId}}Request({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}, {{/allParams}}{{#servers}}{{#-first}}$hostIndex, $variables, {{/-first}}{{/servers}}$contentType{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); +{{#useCustomTemplateCode}} $this->response = $response; +{{/useCustomTemplateCode}} } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", @@ -240,76 +323,78 @@ use {{invokerPackage}}\ObjectSerializer; (string) $response->getBody() ); } - {{#returnType}} - $statusCode = $response->getStatusCode(); - - {{#responses}} - {{#dataType}} - {{^isWildcard}} - {{^isRange}} - if ($statusCode === {{code}}) { - if ('{{{dataType}}}' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } - - return [ - ObjectSerializer::deserialize($content, '{{{dataType}}}', []), - $response->getStatusCode(), - $response->getHeaders() - ]; +{{#useCustomTemplateCode}} + {{#responses}}{{#dataType}}{{#isRange}} + $result = $this->handleRangeCodeResponse( + $response, + '{{code}}', + '{{{dataType}}}' + ); + if ($result) { + return $result; } - {{/isRange}} - {{/isWildcard}} - {{/dataType}} - {{/responses}} - + {{/isRange}}{{/dataType}}{{/responses}} +{{/useCustomTemplateCode}} {{#responses}} - {{#dataType}} - {{#isRange}} - $rangeCodeLeft = (int) (substr('{{code}}', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('{{code}}', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - if ('{{{dataType}}}' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + {{#-first}} - return [ - ObjectSerializer::deserialize($content, '{{{dataType}}}', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - {{/isRange}} - {{/dataType}} - {{/responses}} - - {{#responses}} + switch($statusCode) { + {{/-first}} {{#dataType}} - {{#isWildcard}} - if ('{{{dataType}}}' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - } + {{^isRange}}{{^isWildcard}}case {{code}}:{{/isWildcard}}{{#isWildcard}}default:{{/isWildcard}} + if ('{{{dataType}}}' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('{{{dataType}}}' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } - return [ - ObjectSerializer::deserialize($content, '{{{dataType}}}', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - {{/isWildcard}} + return [ + ObjectSerializer::deserialize($content, '{{{dataType}}}', []), + $response->getStatusCode(), + $response->getHeaders() + ];{{/isRange}} {{/dataType}} + {{#-last}} + } + {{/-last}} {{/responses}} + $returnType = '{{{returnType}}}'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } } return [ @@ -324,58 +409,26 @@ use {{invokerPackage}}\ObjectSerializer; {{/returnType}} } catch (ApiException $e) { - $statusCode = $e->getCode(); - - {{#responses}} +{{#useCustomTemplateCode}} + {{#responses}}{{#dataType}}{{#isRange}} + if ($this->handleRangeCodeException($e, '{{code}}', '{{{dataType}}}')) { + throw $e; + }{{/isRange}}{{/dataType}}{{/responses}} +{{/useCustomTemplateCode}} + switch ($e->getCode()) { + {{#responses}} {{#dataType}} - {{^isWildcard}} - {{^isRange}} - if ($statusCode === {{code}}) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '{{{dataType}}}', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - {{/isRange}} - {{/isWildcard}} - {{/dataType}} - {{/responses}} - - {{#responses}} - {{#dataType}} - {{#isRange}} - $rangeCodeLeft = (int) (substr('{{code}}', 0, 1) . '00'); - $rangeCodeRight = (int) (substr('{{code}}', 0, 1) . '99'); - if ($statusCode >= $rangeCodeLeft && $statusCode <= $rangeCodeRight) { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '{{{dataType}}}', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - } - {{/isRange}} + {{^isRange}}{{^isWildcard}}case {{code}}:{{/isWildcard}}{{#isWildcard}}default:{{/isWildcard}} + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '{{{dataType}}}', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break;{{/isRange}} {{/dataType}} - {{/responses}} - - {{#responses}} - {{#dataType}} - {{#isWildcard}} - $rangeCode = substr('{{code}}', 1); - if ($statusCode >= (int) "{$rangeCode}00" && $statusCode <= (int) "{$rangeCode}99") { - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '{{{dataType}}}', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); + {{/responses}} } - {{/isWildcard}} - {{/dataType}} - {{/responses}} - throw $e; } } @@ -397,9 +450,20 @@ use {{invokerPackage}}\ObjectSerializer; {{/vendorExtensions.x-group-parameters}} {{#servers}} {{#-first}} - * This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. + * if needed, use the 'variables' parameter to pass variables to the host. {{/-first}} * URL: {{{url}}} +{{#variables}} +{{#-first}} + * Variables: +{{/-first}} + * - {{{name}}}: {{{description}}}{{^description}} No description provided{{/description}}{{#enumValues}} +{{#-first}} + * Allowed values: +{{/-first}} + * - {{{.}}}{{/enumValues}} +{{/variables}} {{#-last}} * {{/-last}} @@ -407,16 +471,26 @@ use {{invokerPackage}}\ObjectSerializer; {{#allParams}} * @param {{{dataType}}} ${{paramName}}{{#description}} {{.}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}} {{/allParams}} +{{#servers}} +{{#-first}} + * @param null|int $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead + * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. +{{/-first}} +{{/servers}} + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['{{{operationId}}}'] to see the possible values for this operation * - * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface +{{#useCustomTemplateCode}} + * @deprecated Prefer to use ::{{operationId}}. This method will eventually become unavailable +{{/useCustomTemplateCode}} {{#isDeprecated}} * @deprecated {{/isDeprecated}} */ - public function {{operationId}}Async({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{{defaultValue}}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) + public function {{operationId}}Async({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}, {{/allParams}}{{#servers}}{{#-first}}?int $hostIndex = null, array $variables = [], {{/-first}}{{/servers}}string $contentType = self::contentTypes['{{{operationId}}}'][0]{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) { - return $this->{{operationId}}AsyncWithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) + return $this->{{operationId}}AsyncWithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}, {{/allParams}}{{#servers}}{{#-first}}$hostIndex, $variables, {{/-first}}{{/servers}}$contentType{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) ->then( function ($response) { return $response[0]; @@ -441,9 +515,20 @@ use {{invokerPackage}}\ObjectSerializer; {{/vendorExtensions.x-group-parameters}} {{#servers}} {{#-first}} - * This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. + * if needed, use the 'variables' parameter to pass variables to the host. {{/-first}} * URL: {{{url}}} +{{#variables}} +{{#-first}} + * Variables: +{{/-first}} + * - {{{name}}}: {{{description}}}{{^description}} No description provided{{/description}}{{#enumValues}} +{{#-first}} + * Allowed values: +{{/-first}} + * - {{{.}}}{{/enumValues}} +{{/variables}} {{#-last}} * {{/-last}} @@ -451,17 +536,27 @@ use {{invokerPackage}}\ObjectSerializer; {{#allParams}} * @param {{{dataType}}} ${{paramName}}{{#description}} {{.}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}} {{/allParams}} +{{#servers}} +{{#-first}} + * @param null|int $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead + * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. +{{/-first}} +{{/servers}} + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['{{{operationId}}}'] to see the possible values for this operation * - * @throws InvalidArgumentException - * @return Promise\PromiseInterface + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface +{{#useCustomTemplateCode}} + * @deprecated Prefer to use ::{{operationId}}. This method will eventually become unavailable +{{/useCustomTemplateCode}} {{#isDeprecated}} * @deprecated {{/isDeprecated}} */ - public function {{operationId}}AsyncWithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{{defaultValue}}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) + public function {{operationId}}AsyncWithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}, {{/allParams}}{{#servers}}{{#-first}}?int $hostIndex = null, array $variables = [], {{/-first}}{{/servers}}string $contentType = self::contentTypes['{{{operationId}}}'][0]{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) { $returnType = '{{{returnType}}}'; - $request = $this->{{operationId}}Request({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}); + $request = $this->{{operationId}}Request({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}, {{/allParams}}{{#servers}}{{#-first}}$hostIndex, $variables, {{/-first}}{{/servers}}$contentType{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -472,6 +567,9 @@ use {{invokerPackage}}\ObjectSerializer; $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } } return [ @@ -510,9 +608,20 @@ use {{invokerPackage}}\ObjectSerializer; {{/vendorExtensions.x-group-parameters}} {{#servers}} {{#-first}} - * This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. + * if needed, use the 'variables' parameter to pass variables to the host. {{/-first}} * URL: {{{url}}} +{{#variables}} +{{#-first}} + * Variables: +{{/-first}} + * - {{{name}}}: {{{description}}}{{^description}} No description provided{{/description}}{{#enumValues}} +{{#-first}} + * Allowed values: +{{/-first}} + * - {{{.}}}{{/enumValues}} +{{/variables}} {{#-last}} * {{/-last}} @@ -520,23 +629,35 @@ use {{invokerPackage}}\ObjectSerializer; {{#allParams}} * @param {{{dataType}}} ${{paramName}}{{#description}} {{.}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}} {{/allParams}} +{{#servers}} +{{#-first}} + * @param null|int $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead + * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. +{{/-first}} +{{/servers}} + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['{{{operationId}}}'] to see the possible values for this operation * - * @throws InvalidArgumentException - * @return Psr7\Request + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request +{{#useCustomTemplateCode}} + * @deprecated Prefer to use ::{{operationId}}. This method will eventually become unavailable +{{/useCustomTemplateCode}} {{#isDeprecated}} * @deprecated {{/isDeprecated}} */ - public function {{operationId}}Request({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{{defaultValue}}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) + public function {{operationId}}Request({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}, {{/allParams}}{{#servers}}{{#-first}}?int $hostIndex = null, array $variables = [], {{/-first}}{{/servers}}string $contentType = self::contentTypes['{{{operationId}}}'][0]{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) { {{#vendorExtensions.x-group-parameters}} // unbox the parameters from the associative array - {{#allParams}} +{{#allParams}} ${{paramName}} = array_key_exists('{{paramName}}', $associative_array) ? $associative_array['{{paramName}}'] : {{{defaultValue}}}{{^defaultValue}}null{{/defaultValue}}; - {{/allParams}} - - {{/vendorExtensions.x-group-parameters}} - {{#allParams}} +{{/allParams}}{{#servers.0}} + $hostIndex = $associative_array['hostIndex']; + $variables = array_key_exists('variables', $associative_array) ? $associative_array['variables'] : []; +{{/servers.0}} + $contentType = $associative_array['contentType'] ?? self::contentTypes['{{{operationId}}}'][0]; + {{/vendorExtensions.x-group-parameters}}{{#allParams}} {{#required}} // verify the required parameter '{{paramName}}' is set if (${{paramName}} === null || (is_array(${{paramName}}) && count(${{paramName}}) === 0)) { @@ -581,15 +702,16 @@ use {{invokerPackage}}\ObjectSerializer; throw new \InvalidArgumentException('invalid value for "${{paramName}}" when calling {{classname}}.{{operationId}}, number of items must be greater than or equal to {{minItems}}.'); } {{/minItems}} - - {{/hasValidation}} - {{/allParams}} + {{/hasValidation}}{{/allParams}} $resourcePath = '{{{path}}}'; + $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $multipart = false; +{{#useCustomTemplateCode}} {{#bodyParam}} $formParams = ObjectSerializer::getFormParams( ${{paramName}} @@ -597,38 +719,17 @@ use {{invokerPackage}}\ObjectSerializer; $multipart = !empty($formParams); {{/bodyParam}} - {{^bodyParam}} - $formParams = []; - $multipart = false; - {{/bodyParam}} - +{{/useCustomTemplateCode}} {{#queryParams}} // query params - {{#isExplode}} - if (${{paramName}} !== null) { - {{#style}} - if('form' === '{{style}}' && is_array(${{paramName}})) { - foreach(${{paramName}} as $key => $value) { - $queryParams[$key] = $value; - } - } - else { - $queryParams['{{baseName}}'] = ${{paramName}}; - } - {{/style}} - {{^style}} - $queryParams['{{baseName}}'] = ${{paramName}}; - {{/style}} - } - {{/isExplode}} - {{^isExplode}} - if (is_array(${{paramName}})) { - ${{paramName}} = ObjectSerializer::serializeCollection(${{paramName}}, '{{style}}{{^style}}{{collectionFormat}}{{/style}}', true); - } - if (${{paramName}} !== null) { - $queryParams['{{baseName}}'] = ${{paramName}}; - } - {{/isExplode}} + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + ${{paramName}}, + '{{baseName}}', // param base name + '{{#schema}}{{openApiType}}{{/schema}}', // openApiType + '{{style}}', // style + {{#isExplode}}true{{/isExplode}}{{^isExplode}}false{{/isExplode}}, // explode + {{required}} // required + ) ?? []); {{/queryParams}} {{#headerParams}} @@ -679,22 +780,28 @@ use {{invokerPackage}}\ObjectSerializer; } {{/formParams}} - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['multipart/form-data'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [{{#produces}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/produces}}], - [{{#consumes}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/consumes}}] - ); - } + $headers = $this->headerSelector->selectHeaders( +{{^useCustomTemplateCode}} + [{{#produces}}'{{{mediaType}}}', {{/produces}}], +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} + $multipart ? ['multipart/form-data'] : [{{#produces}}'{{{mediaType}}}', {{/produces}}], +{{/useCustomTemplateCode}} + $contentType, + $multipart + ); // for model (json/xml) {{#bodyParams}} +{{^useCustomTemplateCode}} + if (isset(${{paramName}})) { +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} if (count($formParams) === 0) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization(${{paramName}})); +{{/useCustomTemplateCode}} + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization(${{paramName}})); } else { $httpBody = ${{paramName}}; } @@ -715,6 +822,7 @@ use {{invokerPackage}}\ObjectSerializer; } } // for HTTP post (form) +{{#useCustomTemplateCode}} if (!empty($body)) { $multipartContents[] = [ 'name' => 'body', @@ -728,24 +836,37 @@ use {{invokerPackage}}\ObjectSerializer; $payloadHook('multipart', $multipartContents, ${{paramName}}); } {{/bodyParam}} +{{/useCustomTemplateCode}} + $httpBody = new MultipartStream($multipartContents); - $httpBody = new Psr7\MultipartStream($multipartContents); - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = Utils::jsonEncode($formParams); - + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) - $httpBody = Psr7\Query::build($formParams); + $httpBody = ObjectSerializer::buildQuery($formParams); } } {{#authMethods}} + {{#isApiKey}} + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('{{keyParamName}}'); + if ($apiKey !== null) { + {{#isKeyInHeader}}$headers['{{keyParamName}}'] = $apiKey;{{/isKeyInHeader}}{{#isKeyInQuery}}$queryParams['{{keyParamName}}'] = $apiKey;{{/isKeyInQuery}} + } + {{/isApiKey}} {{#isBasic}} {{#isBasicBasic}} // this endpoint requires HTTP basic authentication +{{^useCustomTemplateCode}} + if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} if (!empty($this->config->getUsername())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ':'); +{{/useCustomTemplateCode}} } {{/isBasicBasic}} {{#isBasicBearer}} @@ -775,33 +896,85 @@ use {{invokerPackage}}\ObjectSerializer; ); {{#servers.0}} - $operationHosts = [{{#servers}}"{{{url}}}"{{^-last}}, {{/-last}}{{/servers}}]; - if ($this->hostIndex < 0 || $this->hostIndex >= sizeof($operationHosts)) { - throw new \InvalidArgumentException("Invalid index {$this->hostIndex} when selecting the host. Must be less than ".sizeof($operationHosts)); + # Preserve the original behavior of server indexing. + if ($hostIndex === null) { + $hostIndex = $this->hostIndex; } - $operationHost = $operationHosts[$this->hostIndex]; + $hostSettings = $this->getHostSettingsFor{{operationId}}(); + + if ($hostIndex < 0 || $hostIndex >= count($hostSettings)) { + throw new \InvalidArgumentException("Invalid index {$hostIndex} when selecting the host. Must be less than ".count($hostSettings)); + } + $operationHost = Configuration::getHostString($hostSettings, $hostIndex, $variables); {{/servers.0}} - $query = Psr7\Query::build($queryParams); - return new Psr7\Request( + {{^servers.0}} + $operationHost = $this->config->getHost(); + {{/servers.0}} + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( '{{httpMethod}}', - {{^servers.0}}$this->config->getHost(){{/servers.0}}{{#servers.0}}$operationHost{{/servers.0}} . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } - {{/operation}} + {{#servers.0}} + /** + * Returns an array of host settings for Operation {{operationId}} + * + * @return array an array of host settings + */ + protected function getHostSettingsFor{{operationId}}(): array + { + return [ + {{#servers}} + [ + "url" => "{{{url}}}", + "description" => "{{{description}}}{{^description}}No description provided{{/description}}", + {{#variables}} + {{#-first}} + "variables" => [ + {{/-first}} + "{{{name}}}" => [ + "description" => "{{{description}}}{{^description}}No description provided{{/description}}", + "default_value" => "{{{defaultValue}}}", + {{#enumValues}} + {{#-first}} + "enum_values" => [ + {{/-first}} + "{{{.}}}", + {{#-last}} + ] + {{/-last}} + {{/enumValues}} + ]{{^-last}},{{/-last}} + {{#-last}} + ] + {{/-last}} + {{/variables}} + ]{{^-last}},{{/-last}} + {{/servers}} + ]; + } + {{/servers.0}} + {{/operation}} /** * Create http client option * - * @throws RuntimeException on file opening failure + * @throws \RuntimeException on file opening failure * @return array of http client options */ protected function createHttpClientOption() { +{{^useCustomTemplateCode}} + $options = []; +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} $options = $this->config->getOptions(); +{{/useCustomTemplateCode}} if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { @@ -811,5 +984,69 @@ use {{invokerPackage}}\ObjectSerializer; return $options; } +{{#useCustomTemplateCode}} + + /** + * @return object|array|null + */ + private function handleRangeCodeResponse( + ResponseInterface $response, + string $rangeCode, + string $returnDataType + ) { + $statusCode = $response->getStatusCode(); + $rangeCodeLeft = (int) (substr($rangeCode, 0, 1) . '00'); + $rangeCodeRight = (int) (substr($rangeCode, 0, 1) . '99'); + + if ( + $statusCode < $rangeCodeLeft + || $statusCode > $rangeCodeRight + ) { + return null; + } + + if ($returnDataType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + } + + return [ + ObjectSerializer::deserialize($content, $returnDataType, []), + $statusCode, + $response->getHeaders(), + ]; + } + + /** + * @return object|array|null + */ + private function handleRangeCodeException( + ApiException $e, + string $rangeCode, + string $exceptionDataType + ): bool { + $statusCode = $e->getCode(); + $rangeCodeLeft = (int) (substr($rangeCode, 0, 1) . '00'); + $rangeCodeRight = (int) (substr($rangeCode, 0, 1) . '99'); + + if ( + $statusCode < $rangeCodeLeft + || $statusCode > $rangeCodeRight + ) { + return false; + } + + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + $exceptionDataType, + $e->getResponseHeaders() + ); + + $e->setResponseObject($data); + + return true; + } +{{/useCustomTemplateCode}} } {{/operations}} diff --git a/sdks/php/templates/api_doc.mustache b/sdks/php/templates/api_doc.mustache index f42a29a8a..6a0b0fc04 100644 --- a/sdks/php/templates/api_doc.mustache +++ b/sdks/php/templates/api_doc.mustache @@ -2,7 +2,12 @@ {{.}}{{/description}} +{{^useCustomTemplateCode}} +All URIs are relative to {{basePath}}, except if the operation defines another base path. +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} All URIs are relative to {{basePath}}. +{{/useCustomTemplateCode}} | Method | HTTP request | Description | | ------------- | ------------- | ------------- | @@ -14,7 +19,23 @@ All URIs are relative to {{basePath}}. ```php {{{operationId}}}({{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}){{#returnType}}: {{{.}}}{{/returnType}} ``` - +{{^useCustomTemplateCode}} +{{#servers}} +{{#-first}} +### URI(s): +{{/-first}} +- {{{url}}} {{#description}}{{.}}{{/description}}{{#variables}} +{{#-first}} + - Variables: +{{/-first}} + - {{{name}}}: {{{description}}}{{^description}} No description provided{{/description}}{{#enumValues}} +{{#-first}} + - Allowed values: +{{/-first}} + - {{{.}}}{{/enumValues}}{{#defaultValue}} + - Default value: {{{.}}} +{{/defaultValue}}{{/variables}}{{/servers}} +{{/useCustomTemplateCode}} {{{summary}}}{{#notes}} {{{.}}}{{/notes}} @@ -22,19 +43,73 @@ All URIs are relative to {{basePath}}. ### Example ```php +{{^useCustomTemplateCode}} + php_doc_auth_partial}} +$apiInstance = new {{invokerPackage}}\Api\{{classname}}( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(){{#hasAuthMethods}}, + $config{{/hasAuthMethods}} +); +{{^vendorExtensions.x-group-parameters}} +{{#allParams}}${{paramName}} = {{{example}}}; // {{{dataType}}}{{#description}} | {{{.}}}{{/description}} +{{/allParams}}{{#servers}}{{#-first}} +$hostIndex = 0; +$variables = [{{#variables}} + '{{{name}}}' => '{{{default}}}{{^default}}YOUR_VALUE{{/default}}',{{/variables}} +]; +{{/-first}}{{/servers}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}} +$associative_array = [ +{{#allParams}} '{{paramName}}' => {{{example}}}, // {{{dataType}}}{{#description}} | {{{.}}}{{/description}} +{{/allParams}} +{{#servers}}{{#-first}} + 'hostIndex' => 0, + $variables = [{{#variables}} + '{{{name}}}' => '{{{default}}}{{^default}}YOUR_VALUE{{/default}}',{{/variables}} + ], +{{/-first}}{{/servers}}]; +{{/vendorExtensions.x-group-parameters}} + +try { + {{#returnType}}$result = {{/returnType}}$apiInstance->{{{operationId}}}({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#servers}}{{#-first}}{{#allParams}}{{#-first}}, {{/-first}}{{/allParams}}$hostIndex, $variables{{/-first}}{{/servers}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associate_array{{/vendorExtensions.x-group-parameters}});{{#returnType}} + print_r($result);{{/returnType}} +} catch (Exception $e) { + echo 'Exception when calling {{classname}}->{{operationId}}: ', $e->getMessage(), PHP_EOL; +} +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} REPLACE_ME_WITH_EXAMPLE_FOR__{{{operationId}}}_PHP_CODE +{{/useCustomTemplateCode}} ``` ### Parameters {{#vendorExtensions.x-group-parameters}} +{{^useCustomTemplateCode}} +Note: the input parameter is an associative array with the keys listed as the parameter names below. +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} Note: the input parameter is an associative array with the keys listed as the parameter name below. +{{/useCustomTemplateCode}} {{/vendorExtensions.x-group-parameters}} +{{^useCustomTemplateCode}} +{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}}| Name | Type | Description | Notes | +| ------------- | ------------- | ------------- | ------------- |{{/-last}}{{/allParams}} +{{#allParams}}| **{{paramName}}** | {{#isFile}}**{{{dataType}}}**{{/isFile}}{{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{{dataType}}}**](../Model/{{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{.}}]{{/defaultValue}} | +{{/allParams}}{{#servers}}{{#-first}}| hostIndex | null|int | Host index. Defaults to null. If null, then the library will use $this->hostIndex instead | [optional] | +| variables | array | Associative array of variables to pass to the host. Defaults to empty array. | [optional] |{{/-first}} +{{/servers}} +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} |{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}}Name | Type | Description | Notes | | ------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} | {{#allParams}}| **{{paramName}}** | {{#isFile}}**{{{dataType}}}**{{/isFile}}{{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{{dataType}}}**](../Model/{{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{.}}]{{/defaultValue}} | {{/allParams}} +{{/useCustomTemplateCode}} ### Return type diff --git a/sdks/php/templates/api_test.mustache b/sdks/php/templates/api_test.mustache index dec28599c..0fc99231c 100644 --- a/sdks/php/templates/api_test.mustache +++ b/sdks/php/templates/api_test.mustache @@ -1,7 +1,7 @@ markTestIncomplete('Not implemented'); + self::markTestIncomplete('Not implemented'); } {{/operation}} } diff --git a/sdks/php/templates/composer.mustache b/sdks/php/templates/composer.mustache index 1ce9ad9c2..85807e08c 100644 --- a/sdks/php/templates/composer.mustache +++ b/sdks/php/templates/composer.mustache @@ -1,6 +1,13 @@ { - "name": "dropbox/sign", - "description": "Official Dropbox Sign APIv3 PHP SDK", + {{#composerPackageName}} + "name": "{{{.}}}", + {{/composerPackageName}} +{{^useCustomTemplateCode}} + {{#artifactVersion}} + "version": "{{{.}}}", + {{/artifactVersion}} +{{/useCustomTemplateCode}} + "description": "{{{appDescription}}}", "keywords": [ "openapitools", "openapi-generator", @@ -8,23 +15,27 @@ "php", "sdk", "rest", +{{^useCustomTemplateCode}} + "api" +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} "api", "hellosign", "dropboxsign" +{{/useCustomTemplateCode}} ], - "homepage": "https://hellosign.com", - "license": [ - "MIT" - ], + "homepage": "{{{artifactUrl}}}", + "license": "{{{licenseName}}}", "authors": [ { - "name": "Dropbox Sign", - "homepage": "https://hellosign.com", - "email": "apisupport@hellosign.com" - }, - { - "name": "OpenAPI-Generator contributors", - "homepage": "https://openapi-generator.tech" + "name": "{{{developerOrganization}}}", +{{^useCustomTemplateCode}} + "homepage": "{{{developerOrganizationUrl}}}" +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} + "homepage": "{{{developerOrganizationUrl}}}", + "email": "{{{developerOrganizationEmail}}}" +{{/useCustomTemplateCode}} } ], "require": { @@ -37,15 +48,18 @@ }, "require-dev": { "phpunit/phpunit": "^8.0 || ^9.0", - "friendsofphp/php-cs-fixer": "3.4.*", +{{^useCustomTemplateCode}} + "friendsofphp/php-cs-fixer": "^3.5" +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} + "friendsofphp/php-cs-fixer": "^3.5", "symfony/yaml": "^5.4" +{{/useCustomTemplateCode}} }, "autoload": { - "psr-4": { - "{{escapedInvokerPackage}}\\": "{{srcBasePath}}/" - } + "psr-4": { "{{{escapedInvokerPackage}}}\\" : "{{{srcBasePath}}}/" } }, "autoload-dev": { - "psr-4": { "{{escapedInvokerPackage}}\\Test\\" : "{{testBasePath}}/" } + "psr-4": { "{{{escapedInvokerPackage}}}\\Test\\" : "{{{testBasePath}}}/" } } } diff --git a/sdks/php/templates/gitignore b/sdks/php/templates/gitignore index 3f10c0389..12f85db8f 100644 --- a/sdks/php/templates/gitignore +++ b/sdks/php/templates/gitignore @@ -14,7 +14,9 @@ composer.phar # PHPUnit cache .phpunit.result.cache +# CUSTOM - BEGIN .composer .openapi-generator git_push.sh composer.lock +# CUSTOM - END diff --git a/sdks/php/templates/libraries/psr-18/ApiException.mustache b/sdks/php/templates/libraries/psr-18/ApiException.mustache new file mode 100644 index 000000000..336d8f7c5 --- /dev/null +++ b/sdks/php/templates/libraries/psr-18/ApiException.mustache @@ -0,0 +1,119 @@ +partial_header}} +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +namespace {{invokerPackage}}; + +use Exception; +use Http\Client\Exception\RequestException; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; + +/** + * ApiException Class Doc Comment + * + * @category Class + * @package {{invokerPackage}} + * @author OpenAPI Generator team + * @link https://openapi-generator.tech + */ +class ApiException extends RequestException +{ + + /** + * The HTTP body of the server response either as Json or string. + * + * @var string|null + */ + protected $responseBody; + + /** + * The HTTP header of the server response. + * + * @var string[][]|null + */ + protected $responseHeaders; + + /** + * The deserialized response object + * + * @var \stdClass|string|null + */ + protected $responseObject; + + public function __construct( + $message, + RequestInterface $request, + ResponseInterface $response = null, + Exception $previous = null + ) { + parent::__construct($message, $request, $previous); + if ($response) { + $this->responseHeaders = $response->getHeaders(); + $this->responseBody = (string) $response->getBody(); + $this->code = $response->getStatusCode(); + } + } + + /** + * Gets the HTTP response header + * + * @return string[][]|null HTTP response header + */ + public function getResponseHeaders() + { + return $this->responseHeaders; + } + + /** + * Gets the HTTP body of the server response either as Json or string + * + * @return \stdClass|string|null HTTP body of the server response either as \stdClass or string + */ + public function getResponseBody() + { + return $this->responseBody; + } + + /** + * Sets the deseralized response object (during deserialization) + * +{{^useCustomTemplateCode}} + * @param mixed $obj Deserialized response object +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} + * @param string|int|object|array|mixed $obj Deserialized response object +{{/useCustomTemplateCode}} + + * + * @return void + */ + public function setResponseObject($obj) + { + $this->responseObject = $obj; + } + + /** + * Gets the deseralized response object (during deserialization) + * + * @return mixed the deserialized response object + */ + public function getResponseObject() + { + return $this->responseObject; + } +} diff --git a/sdks/php/templates/libraries/psr-18/DebugPlugin.mustache b/sdks/php/templates/libraries/psr-18/DebugPlugin.mustache new file mode 100644 index 000000000..cf256a130 --- /dev/null +++ b/sdks/php/templates/libraries/psr-18/DebugPlugin.mustache @@ -0,0 +1,92 @@ +partial_header}} +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +namespace {{invokerPackage}}; + +use Http\Client\Common\Plugin; +use Http\Promise\Promise; +use Psr\Http\Client\ClientExceptionInterface; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; +use function is_resource; + +/** + * Configuration Class Doc Comment + * PHP version 7.2 + * + * @category Class + * @package {{invokerPackage}} + * @author OpenAPI Generator team + * @link https://openapi-generator.tech + */ +class DebugPlugin implements Plugin +{ + + /** + * @var resource + */ + private $output; + + /** + * DebuggingPlugin constructor. + * + * @param resource $output + */ + public function __construct($output) + { + if (!is_resource($output)) { + throw new \InvalidArgumentException('debugging resource is not valid'); + } + $this->output = $output; + } + + public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise + { + return $next($request)->then( + function (ResponseInterface $response) use ($request) { + $this->logSuccess($request, $response); + + return $response; + }, + function (ClientExceptionInterface $exception) use ($request) { + $this->logError($request, $exception); + + throw $exception; + } + ); + } + + private function logSuccess(RequestInterface $request, ResponseInterface $response): void + { + $methodAndPath = $request->getMethod() . ' ' . $request->getUri()->getPath(); + $protocol = $response->getProtocolVersion(); + $responseCode = $response->getStatusCode(); + \fprintf($this->output, '<%s HTTP/%s> %s', $methodAndPath, $protocol, $responseCode); + \fwrite($this->output, "\n"); + } + + private function logError(RequestInterface $request, ClientExceptionInterface $exception): void + { + $methodAndPath = $request->getMethod() . ' ' . $request->getUri()->getPath(); + $protocol = $request->getProtocolVersion(); + $error = $exception->getMessage(); + $responseCode = $exception->getCode(); + \fprintf($this->output, '<%s HTTP/%s> %s %s', $methodAndPath, $responseCode, $error, $protocol); + \fwrite($this->output, "\n"); + } +} \ No newline at end of file diff --git a/sdks/php/templates/libraries/psr-18/README.mustache b/sdks/php/templates/libraries/psr-18/README.mustache new file mode 100644 index 000000000..40a12d592 --- /dev/null +++ b/sdks/php/templates/libraries/psr-18/README.mustache @@ -0,0 +1,160 @@ +# {{packageName}} + +{{#appDescriptionWithNewLines}} +{{{appDescriptionWithNewLines}}} +{{/appDescriptionWithNewLines}} + +{{#infoUrl}} +For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}). +{{/infoUrl}} + +## Installation & Usage + +### Requirements + +PHP 7.2 and later. + +### Composer + +To install the bindings via [Composer](https://getcomposer.org/), add the following to `composer.json`: + +```json +{ + "repositories": [ + { + "type": "vcs", + "url": "https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}.git" + } + ], + "require": { + "{{gitUserId}}/{{gitRepoId}}": "*@dev" + } +} +``` + +Then run `composer install` + +Your project is free to choose the http client of your choice +Please require packages that will provide http client functionality: +https://packagist.org/providers/psr/http-client-implementation +https://packagist.org/providers/php-http/async-client-implementation +https://packagist.org/providers/psr/http-factory-implementation + +As an example: + +``` +composer require guzzlehttp/guzzle php-http/guzzle7-adapter http-interop/http-factory-guzzle +``` + +### Manual Installation + +Download the files and include `autoload.php`: + +```php + php_doc_auth_partial}} +$apiInstance = new {{invokerPackage}}\Api\{{classname}}( + // If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`. + // This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface + new GuzzleHttp\Client(){{#hasAuthMethods}}, + $config{{/hasAuthMethods}} +); +{{#allParams}}${{paramName}} = {{{example}}}; // {{{dataType}}}{{#description}} | {{{description}}}{{/description}} +{{/allParams}} + +try { + {{#returnType}}$result = {{/returnType}}$apiInstance->{{{operationId}}}({{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}});{{#returnType}} + print_r($result);{{/returnType}} +} catch (Exception $e) { + echo 'Exception when calling {{classname}}->{{operationId}}: ', $e->getMessage(), PHP_EOL; +} +{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} +``` + +## API Endpoints + +All URIs are relative to *{{basePath}}* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}/{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} +## Models + +{{#models}}{{#model}}- [{{{classname}}}]({{modelDocPath}}/{{{classname}}}.md){{/model}} +{{/models}} + +## Authorization +{{^authMethods}} +All endpoints do not require authorization. +{{/authMethods}} +{{#authMethods}} +{{#last}} Authentication schemes defined for the API:{{/last}} +### {{{name}}} +{{#isApiKey}} + +- **Type**: API key +- **API key parameter name**: {{{keyParamName}}} +- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} + +{{/isApiKey}} +{{#isBasic}} +{{#isBasicBasic}} + +- **Type**: HTTP basic authentication +{{/isBasicBasic}} +{{#isBasicBearer}} + +- **Type**: Bearer authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} +{{/isBasicBearer}} +{{/isBasic}} +{{#isOAuth}} + +- **Type**: `OAuth` +- **Flow**: `{{{flow}}}` +- **Authorization URL**: `{{{authorizationUrl}}}` +- **Scopes**: {{^scopes}}N/A{{/scopes}} +{{#scopes}} + - **{{{scope}}}**: {{{description}}} +{{/scopes}} +{{/isOAuth}} + +{{/authMethods}} +## Tests + +To run the tests, use: + +```bash +composer install +vendor/bin/phpunit +``` + +## Author + +{{#apiInfo}}{{#apis}}{{#-last}}{{infoEmail}} +{{/-last}}{{/apis}}{{/apiInfo}} +## About this package + +This PHP package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: + +- API version: `{{appVersion}}` +{{#artifactVersion}} + - Package version: `{{artifactVersion}}` +{{/artifactVersion}} +{{^hideGenerationTimestamp}} + - Build date: `{{generatedDate}}` +{{/hideGenerationTimestamp}} + - Generator version: `{{generatorVersion}}` +- Build package: `{{generatorClass}}` diff --git a/sdks/php/templates/libraries/psr-18/api.mustache b/sdks/php/templates/libraries/psr-18/api.mustache new file mode 100644 index 000000000..6138ab176 --- /dev/null +++ b/sdks/php/templates/libraries/psr-18/api.mustache @@ -0,0 +1,773 @@ +partial_header}} +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +namespace {{apiPackage}}; + +use GuzzleHttp\Psr7\MultipartStream; +use Http\Client\Common\Plugin\ErrorPlugin; +use Http\Client\Common\Plugin\RedirectPlugin; +use Http\Client\Common\PluginClient; +use Http\Client\Common\PluginClientFactory; +use Http\Client\Exception\HttpException; +use Http\Client\HttpAsyncClient; +use Http\Discovery\HttpAsyncClientDiscovery; +use Http\Discovery\Psr17FactoryDiscovery; +use Http\Discovery\Psr18ClientDiscovery; +use Http\Message\RequestFactory; +use Http\Promise\Promise; +use {{invokerPackage}}\ApiException; +use {{invokerPackage}}\Configuration; +use {{invokerPackage}}\DebugPlugin; +use {{invokerPackage}}\HeaderSelector; +use {{invokerPackage}}\ObjectSerializer; +use Psr\Http\Client\ClientExceptionInterface; +use Psr\Http\Client\ClientInterface; +use Psr\Http\Message\RequestFactoryInterface; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\StreamFactoryInterface; +use Psr\Http\Message\UriFactoryInterface; +use Psr\Http\Message\UriInterface; +use function sprintf; + +/** + * {{classname}} Class Doc Comment + * + * @category Class + * @package {{invokerPackage}} + * @author OpenAPI Generator team + * @link https://openapi-generator.tech + */ +{{#operations}}class {{classname}} +{ + /** + * @var PluginClient + */ + protected $httpClient; + + /** + * @var PluginClient + */ + protected $httpAsyncClient; + + /** + * @var UriFactoryInterface + */ + protected $uriFactory; + + /** + * @var Configuration + */ + protected $config; + + /** + * @var HeaderSelector + */ + protected $headerSelector; + + /** + * @var int Host index + */ + protected $hostIndex; + + /** + * @var RequestFactoryInterface + */ + protected $requestFactory; + + /** + * @var StreamFactoryInterface + */ + protected $streamFactory; + + public function __construct( + ClientInterface $httpClient = null, + Configuration $config = null, + HttpAsyncClient $httpAsyncClient = null, + UriFactoryInterface $uriFactory = null, + RequestFactoryInterface $requestFactory = null, + StreamFactoryInterface $streamFactory = null, + HeaderSelector $selector = null, + ?array $plugins = null, + $hostIndex = 0 + ) { + $this->config = $config ?? (new Configuration())->setHost('{{basePath}}'); + $this->requestFactory = $requestFactory ?? Psr17FactoryDiscovery::findRequestFactory(); + $this->streamFactory = $streamFactory ?? Psr17FactoryDiscovery::findStreamFactory(); + + $plugins = $plugins ?? [ + new RedirectPlugin(['strict' => true]), + new ErrorPlugin(), + ]; + + if ($this->config->getDebug()) { + $plugins[] = new DebugPlugin(fopen($this->config->getDebugFile(), 'ab')); + } + + $this->httpClient = (new PluginClientFactory())->createClient( + $httpClient ?? Psr18ClientDiscovery::find(), + $plugins + ); + + $this->httpAsyncClient = (new PluginClientFactory())->createClient( + $httpAsyncClient ?? HttpAsyncClientDiscovery::find(), + $plugins + ); + + $this->uriFactory = $uriFactory ?? Psr17FactoryDiscovery::findUriFactory(); + + $this->headerSelector = $selector ?? new HeaderSelector(); + + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + +{{#operation}} + /** + * Operation {{{operationId}}} +{{#summary}} + * + * {{.}} +{{/summary}} + * +{{#description}} + * {{.}} + * +{{/description}} +{{#vendorExtensions.x-group-parameters}} + * Note: the input parameter is an associative array with the keys listed as the parameter name below + * +{{/vendorExtensions.x-group-parameters}} +{{#servers}} +{{#-first}} + * This oepration contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. +{{/-first}} + * URL: {{{url}}} +{{#-last}} + * +{{/-last}} +{{/servers}} +{{#allParams}} + * @param {{{dataType}}} ${{paramName}}{{#description}} {{description}}{{/description}}{{^description}} {{paramName}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} +{{/allParams}} + * + * @throws \{{invokerPackage}}\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return {{#returnType}}{{#responses}}{{#dataType}}{{^-first}}|{{/-first}}{{/dataType}}{{{dataType}}}{{/responses}}{{/returnType}}{{^returnType}}void{{/returnType}} + */ + public function {{operationId}}({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) + { + {{#returnType}}list($response) = {{/returnType}}$this->{{operationId}}WithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}});{{#returnType}} + return $response;{{/returnType}} + } + + /** + * Operation {{{operationId}}}WithHttpInfo +{{#summary}} + * + * {{.}} +{{/summary}} + * +{{#description}} + * {{.}} + * +{{/description}} +{{#vendorExtensions.x-group-parameters}} + * Note: the input parameter is an associative array with the keys listed as the parameter name below + * +{{/vendorExtensions.x-group-parameters}} +{{#servers}} +{{#-first}} + * This oepration contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. +{{/-first}} + * URL: {{{url}}} +{{#-last}} + * +{{/-last}} +{{/servers}} +{{#allParams}} + * @param {{{dataType}}} ${{paramName}}{{#description}} {{description}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} +{{/allParams}} + * + * @throws \{{invokerPackage}}\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of {{#returnType}}{{#responses}}{{#dataType}}{{^-first}}|{{/-first}}{{/dataType}}{{{dataType}}}{{/responses}}{{/returnType}}{{^returnType}}null{{/returnType}}, HTTP status code, HTTP response headers (array of strings) + */ + public function {{operationId}}WithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) + { + $request = $this->{{operationId}}Request({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}); + + try { + try { + $response = $this->httpClient->sendRequest($request); + } catch (HttpException $e) { + $response = $e->getResponse(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $response->getStatusCode(), + (string) $request->getUri() + ), + $request, + $response, + $e + ); + } catch (ClientExceptionInterface $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $request, + null, + $e + ); + } + + $statusCode = $response->getStatusCode(); + {{#returnType}} + {{#responses}} + {{#-first}} + + switch($statusCode) { + {{/-first}} + {{#dataType}} + {{^isWildcard}}case {{code}}:{{/isWildcard}}{{#isWildcard}}default:{{/isWildcard}} + if ('{{{dataType}}}' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + } + + return [ + ObjectSerializer::deserialize($content, '{{{dataType}}}', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + {{/dataType}} + {{#-last}} + } + {{/-last}} + {{/responses}} + + $returnType = '{{{returnType}}}'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + {{/returnType}} + {{^returnType}} + + return [null, $statusCode, $response->getHeaders()]; + {{/returnType}} + + } catch (ApiException $e) { + switch ($e->getCode()) { + {{#responses}} + {{#dataType}} + {{^isWildcard}}case {{code}}:{{/isWildcard}}{{#isWildcard}}default:{{/isWildcard}} + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '{{{dataType}}}', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + {{/dataType}} + {{/responses}} + } + throw $e; + } + } + + /** + * Operation {{{operationId}}}Async + * +{{#summary}} + * {{.}} + * +{{/summary}} +{{#description}} + * {{.}} + * +{{/description}} +{{#vendorExtensions.x-group-parameters}} + * Note: the input parameter is an associative array with the keys listed as the parameter name below + * +{{/vendorExtensions.x-group-parameters}} +{{#servers}} +{{#-first}} + * This oepration contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. +{{/-first}} + * URL: {{{url}}} +{{#-last}} + * +{{/-last}} +{{/servers}} +{{#allParams}} + * @param {{{dataType}}} ${{paramName}}{{#description}} {{description}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} +{{/allParams}} + * + * @throws \InvalidArgumentException + * @return Promise + */ + public function {{operationId}}Async({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) + { + return $this->{{operationId}}AsyncWithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation {{{operationId}}}AsyncWithHttpInfo + * +{{#summary}} + * {{.}} + * +{{/summary}} +{{#description}} + * {{.}} + * +{{/description}} +{{#vendorExtensions.x-group-parameters}} + * Note: the input parameter is an associative array with the keys listed as the parameter name below + * +{{/vendorExtensions.x-group-parameters}} +{{#servers}} +{{#-first}} + * This oepration contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. +{{/-first}} + * URL: {{{url}}} +{{#-last}} + * +{{/-last}} +{{/servers}} +{{#allParams}} + * @param {{{dataType}}} ${{paramName}}{{#description}} {{description}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} +{{/allParams}} + * + * @throws \InvalidArgumentException + * @return Promise + */ + public function {{operationId}}AsyncWithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) + { + $returnType = '{{{returnType}}}'; + $request = $this->{{operationId}}Request({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}); + + return $this->httpAsyncClient->sendAsyncRequest($request) + ->then( + function ($response) use ($returnType) { + {{#returnType}} + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + {{/returnType}} + {{^returnType}} + return [null, $response->getStatusCode(), $response->getHeaders()]; + {{/returnType}} + }, + function (HttpException $exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $exception->getRequest(), + $exception->getResponse(), + $exception + ); + } + ); + } + + /** + * Create request for operation '{{{operationId}}}' + * +{{#vendorExtensions.x-group-parameters}} + * Note: the input parameter is an associative array with the keys listed as the parameter name below + * +{{/vendorExtensions.x-group-parameters}} +{{#servers}} +{{#-first}} + * This oepration contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. +{{/-first}} + * URL: {{{url}}} +{{#-last}} + * +{{/-last}} +{{/servers}} +{{#allParams}} + * @param {{{dataType}}} ${{paramName}}{{#description}} {{description}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} +{{/allParams}} + * + * @throws \InvalidArgumentException + * @return RequestInterface + */ + public function {{operationId}}Request({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) + { + {{#vendorExtensions.x-group-parameters}} + // unbox the parameters from the associative array + {{#allParams}} + ${{paramName}} = array_key_exists('{{paramName}}', $associative_array) ? $associative_array['{{paramName}}'] : {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}; + {{/allParams}} + + {{/vendorExtensions.x-group-parameters}} + {{#allParams}} + {{#required}} + // verify the required parameter '{{paramName}}' is set + if (${{paramName}} === null || (is_array(${{paramName}}) && count(${{paramName}}) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter ${{paramName}} when calling {{operationId}}' + ); + } + {{/required}} + {{#hasValidation}} + {{#maxLength}} + if ({{^required}}${{paramName}} !== null && {{/required}}strlen(${{paramName}}) > {{maxLength}}) { + throw new \InvalidArgumentException('invalid length for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maxLength}}.'); + } + {{/maxLength}} + {{#minLength}} + if ({{^required}}${{paramName}} !== null && {{/required}}strlen(${{paramName}}) < {{minLength}}) { + throw new \InvalidArgumentException('invalid length for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minLength}}.'); + } + {{/minLength}} + {{#maximum}} + if ({{^required}}${{paramName}} !== null && {{/required}}${{paramName}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}) { + throw new \InvalidArgumentException('invalid value for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{maximum}}.'); + } + {{/maximum}} + {{#minimum}} + if ({{^required}}${{paramName}} !== null && {{/required}}${{paramName}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}) { + throw new \InvalidArgumentException('invalid value for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be bigger than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{minimum}}.'); + } + {{/minimum}} + {{#pattern}} + if ({{^required}}${{paramName}} !== null && {{/required}}!preg_match("{{{pattern}}}", ${{paramName}})) { + throw new \InvalidArgumentException("invalid value for \"{{paramName}}\" when calling {{classname}}.{{operationId}}, must conform to the pattern {{{pattern}}}."); + } + {{/pattern}} + {{#maxItems}} + if ({{^required}}${{paramName}} !== null && {{/required}}count(${{paramName}}) > {{maxItems}}) { + throw new \InvalidArgumentException('invalid value for "${{paramName}}" when calling {{classname}}.{{operationId}}, number of items must be less than or equal to {{maxItems}}.'); + } + {{/maxItems}} + {{#minItems}} + if ({{^required}}${{paramName}} !== null && {{/required}}count(${{paramName}}) < {{minItems}}) { + throw new \InvalidArgumentException('invalid value for "${{paramName}}" when calling {{classname}}.{{operationId}}, number of items must be greater than or equal to {{minItems}}.'); + } + {{/minItems}} + + {{/hasValidation}} + {{/allParams}} + + $resourcePath = '{{{path}}}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = null; + $multipart = false; + + {{#queryParams}} + // query params + {{#isExplode}} + if (${{paramName}} !== null) { + {{#style}} + if('form' === '{{style}}' && is_array(${{paramName}})) { + foreach(${{paramName}} as $key => $value) { + $queryParams[$key] = $value; + } + } + else { + $queryParams['{{baseName}}'] = ${{paramName}}; + } + {{/style}} + {{^style}} + $queryParams['{{baseName}}'] = ${{paramName}}; + {{/style}} + } + {{/isExplode}} + {{^isExplode}} + if (is_array(${{paramName}})) { + ${{paramName}} = ObjectSerializer::serializeCollection(${{paramName}}, '{{#style}}{{style}}{{/style}}{{^style}}{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}{{/style}}', true); + } + if (${{paramName}} !== null) { + $queryParams['{{baseName}}'] = ${{paramName}}; + } + {{/isExplode}} + {{/queryParams}} + + {{#headerParams}} + // header params + {{#collectionFormat}} + if (is_array(${{paramName}})) { + ${{paramName}} = ObjectSerializer::serializeCollection(${{paramName}}, '{{collectionFormat}}'); + } + {{/collectionFormat}} + if (${{paramName}} !== null) { + $headerParams['{{baseName}}'] = ObjectSerializer::toHeaderValue(${{paramName}}); + } + {{/headerParams}} + + {{#pathParams}} + // path params + {{#collectionFormat}} + if (is_array(${{paramName}})) { + ${{paramName}} = ObjectSerializer::serializeCollection(${{paramName}}, '{{collectionFormat}}'); + } + {{/collectionFormat}} + if (${{paramName}} !== null) { + $resourcePath = str_replace( + '{' . '{{baseName}}' . '}', + ObjectSerializer::toPathValue(${{paramName}}), + $resourcePath + ); + } + {{/pathParams}} + + {{#formParams}} + // form params + if (${{paramName}} !== null) { + {{#isFile}} + $multipart = true; + $formParams['{{baseName}}'] = []; + $paramFiles = is_array(${{paramName}}) ? ${{paramName}} : [${{paramName}}]; + foreach ($paramFiles as $paramFile) { + $formParams['{{baseName}}'][] = \GuzzleHttp\Psr7\try_fopen( + ObjectSerializer::toFormValue($paramFile), + 'rb' + ); + } + {{/isFile}} + {{^isFile}} + $formParams['{{baseName}}'] = ObjectSerializer::toFormValue(${{paramName}}); + {{/isFile}} + } + {{/formParams}} + + $headers = $this->headerSelector->selectHeaders( + [{{#produces}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/produces}}], + '{{#consumes}}{{{mediaType}}}{{/consumes}}', + $multipart + ); + + // for model (json/xml) + {{#bodyParams}} + if (isset(${{paramName}})) { + if ($headers['Content-Type'] === 'application/json') { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization(${{paramName}})); + } else { + $httpBody = ${{paramName}}; + } + } elseif (count($formParams) > 0) { + {{/bodyParams}} + {{^bodyParams}} + if (count($formParams) > 0) { + {{/bodyParams}} + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + {{#authMethods}} + {{#isApiKey}} + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('{{keyParamName}}'); + if ($apiKey !== null) { + {{#isKeyInHeader}}$headers['{{keyParamName}}'] = $apiKey;{{/isKeyInHeader}}{{#isKeyInQuery}}$queryParams['{{keyParamName}}'] = $apiKey;{{/isKeyInQuery}} + } + {{/isApiKey}} + {{#isBasic}} + {{#isBasicBasic}} + // this endpoint requires HTTP basic authentication + if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + {{/isBasicBasic}} + {{#isBasicBearer}} + // this endpoint requires Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} authentication (access token) + if ($this->config->getAccessToken() !== null) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + {{/isBasicBearer}} + {{/isBasic}} + {{#isOAuth}} + // this endpoint requires OAuth (access token) + if ($this->config->getAccessToken() !== null) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + {{/isOAuth}} + {{/authMethods}} + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + {{^servers.0}} + $operationHost = $this->config->getHost(); + {{/servers.0}} + {{#servers.0}} + $operationHosts = [{{#servers}}"{{{url}}}"{{^-last}}, {{/-last}}{{/servers}}]; + if ($this->hostIndex < 0 || $this->hostIndex >= sizeof($operationHosts)) { + throw new \InvalidArgumentException("Invalid index {$this->hostIndex} when selecting the host. Must be less than ".sizeof($operationHosts)); + } + $operationHost = $operationHosts[$this->hostIndex]; + {{/servers.0}} + + $uri = $this->createUri($operationHost, $resourcePath, $queryParams); + + return $this->createRequest('{{httpMethod}}', $uri, $headers, $httpBody); + } + + {{/operation}} + + /** + * @param string $method + * @param string|UriInterface $uri + * @param array $headers + * @param string|StreamInterface|null $body + * + * @return RequestInterface + */ + protected function createRequest(string $method, $uri, array $headers = [], $body = null): RequestInterface + { + if ($this->requestFactory instanceof RequestFactory) { + return $this->requestFactory->createRequest( + $method, + $uri, + $headers, + $body + ); + } + + if (is_string($body) && '' !== $body && null === $this->streamFactory) { + throw new \RuntimeException('Cannot create request: A stream factory is required to create a request with a non-empty string body.'); + } + + $request = $this->requestFactory->createRequest($method, $uri); + + foreach ($headers as $key => $value) { + $request = $request->withHeader($key, $value); + } + + if (null !== $body && '' !== $body) { + $request = $request->withBody( + is_string($body) ? $this->streamFactory->createStream($body) : $body + ); + } + + return $request; + } + + private function createUri( + string $operationHost, + string $resourcePath, + array $queryParams + ): UriInterface { + $parsedUrl = parse_url($operationHost); + + $host = $parsedUrl['host'] ?? null; + $scheme = $parsedUrl['scheme'] ?? null; + $basePath = $parsedUrl['path'] ?? null; + $port = $parsedUrl['port'] ?? null; + $user = $parsedUrl['user'] ?? null; + $password = $parsedUrl['pass'] ?? null; + + $uri = $this->uriFactory->createUri($basePath . $resourcePath) + ->withHost($host) + ->withScheme($scheme) + ->withPort($port) + ->withQuery(ObjectSerializer::buildQuery($queryParams)); + + if ($user) { + $uri = $uri->withUserInfo($user, $password); + } + + return $uri; + } +} +{{/operations}} diff --git a/sdks/php/templates/libraries/psr-18/api_doc.mustache b/sdks/php/templates/libraries/psr-18/api_doc.mustache new file mode 100644 index 000000000..3a794f7e5 --- /dev/null +++ b/sdks/php/templates/libraries/psr-18/api_doc.mustache @@ -0,0 +1,78 @@ +# {{invokerPackage}}\{{classname}}{{#description}} + +{{description}}{{/description}} + +All URIs are relative to {{basePath}}. + +Method | HTTP request | Description +------------- | ------------- | ------------- +{{#operations}}{{#operation}}[**{{operationId}}()**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}}{{#operations}}{{#operation}} + +## `{{{operationId}}}()` + +```php +{{{operationId}}}({{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}){{#returnType}}: {{{returnType}}}{{/returnType}} +``` + +{{{summary}}}{{#notes}} + +{{{notes}}}{{/notes}} + +### Example + +```php + php_doc_auth_partial}} +$apiInstance = new {{invokerPackage}}\Api\{{classname}}( + // If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`. + // This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface + new GuzzleHttp\Client(){{#hasAuthMethods}}, + $config{{/hasAuthMethods}} +); +{{^vendorExtensions.x-group-parameters}} +{{#allParams}}${{paramName}} = {{{example}}}; // {{{dataType}}}{{#description}} | {{{description}}}{{/description}} +{{/allParams}} +{{/vendorExtensions.x-group-parameters}} +{{#vendorExtensions.x-group-parameters}} +{{#allParams}}$associate_array['{{paramName}}'] = {{{example}}}; // {{{dataType}}}{{#description}} | {{{description}}}{{/description}} +{{/allParams}} +{{/vendorExtensions.x-group-parameters}} + +try { + {{#returnType}}$result = {{/returnType}}$apiInstance->{{{operationId}}}({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associate_array{{/vendorExtensions.x-group-parameters}});{{#returnType}} + print_r($result);{{/returnType}} +} catch (Exception $e) { + echo 'Exception when calling {{classname}}->{{operationId}}: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +{{#vendorExtensions.x-group-parameters}} +Note: the input parameter is an associative array with the keys listed as the parameter name below. + +{{/vendorExtensions.x-group-parameters}} +{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}}Name | Type | Description | Notes +------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} +{{#allParams}} **{{paramName}}** | {{#isFile}}**{{{dataType}}}**{{/isFile}}{{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{{dataType}}}**](../Model/{{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{defaultValue}}]{{/defaultValue}} +{{/allParams}} + +### Return type + +{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**](../Model/{{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void (empty response body){{/returnType}} + +### Authorization + +{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}} + +### HTTP request headers + +- **Content-Type**: {{#consumes}}`{{{mediaType}}}`{{^-last}}, {{/-last}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} +- **Accept**: {{#produces}}`{{{mediaType}}}`{{^-last}}, {{/-last}}{{/produces}}{{^produces}}Not defined{{/produces}} + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md){{/operation}}{{/operations}} diff --git a/sdks/php/templates/libraries/psr-18/composer.mustache b/sdks/php/templates/libraries/psr-18/composer.mustache new file mode 100644 index 000000000..7ef3e16b0 --- /dev/null +++ b/sdks/php/templates/libraries/psr-18/composer.mustache @@ -0,0 +1,54 @@ +{ + "name": "{{gitUserId}}/{{gitRepoId}}", + {{#artifactVersion}} + "version": "{{artifactVersion}}", + {{/artifactVersion}} + "description": "{{{appDescription}}}", + "keywords": [ + "openapitools", + "openapi-generator", + "openapi", + "php", + "sdk", + "rest", + "api" + ], + "homepage": "https://openapi-generator.tech", + "license": "unlicense", + "authors": [ + { + "name": "OpenAPI-Generator contributors", + "homepage": "https://openapi-generator.tech" + } + ], + "config": { + "sort-packages": true + }, + "require": { + "php": ">=7.2", + "ext-curl": "*", + "ext-json": "*", + "ext-mbstring": "*", + "guzzlehttp/psr7": "^1.8 || ^2.0", + "php-http/async-client-implementation": "^1.0", + "php-http/client-common": "^2.4", + "php-http/discovery": "^1.14", + "php-http/httplug": "^2.2", + "psr/http-client-implementation": "^1.0", + "psr/http-factory": "^1.0", + "psr/http-factory-implementation": "^1.0", + "psr/http-message": "^1.0" + }, + "require-dev": { + "phpunit/phpunit": "^8.0 || ^9.0", + "friendsofphp/php-cs-fixer": "^2.12", + "guzzlehttp/guzzle": "^7.0", + "php-http/guzzle7-adapter": "^1.0" + }, + "autoload": { + "psr-4": { "{{escapedInvokerPackage}}\\" : "{{srcBasePath}}/" } + }, + "autoload-dev": { + "psr-4": { "{{escapedInvokerPackage}}\\Test\\" : "{{testBasePath}}/" } + } +} diff --git a/sdks/php/templates/model.mustache b/sdks/php/templates/model.mustache index f0f5f1843..fe57ed7e5 100644 --- a/sdks/php/templates/model.mustache +++ b/sdks/php/templates/model.mustache @@ -4,7 +4,7 @@ /** * {{classname}} * - * PHP version {{phpVersion}} + * PHP version 7.4 * * @category Class * @package {{invokerPackage}} @@ -27,7 +27,6 @@ use \ArrayAccess; {{/parentSchema}} {{/isEnum}} use \{{invokerPackage}}\ObjectSerializer; -use ReturnTypeWillChange; /** * {{classname}} Class Doc Comment @@ -40,11 +39,8 @@ use ReturnTypeWillChange; * @author OpenAPI Generator team * @link https://openapi-generator.tech {{^isEnum}} - * @implements \ArrayAccess - * @template TKey int|null - * @template TValue mixed|null + * @implements \ArrayAccess {{/isEnum}} - * {{#vendorExtensions.x-internal-class}}@internal This class should not be instantiated directly{{/vendorExtensions.x-internal-class}} */ {{#isEnum}}{{>model_enum}}{{/isEnum}}{{^isEnum}}{{>model_generic}}{{/isEnum}} {{/model}}{{/models}} diff --git a/sdks/php/templates/model_doc.mustache b/sdks/php/templates/model_doc.mustache index 3f3578894..935522686 100644 --- a/sdks/php/templates/model_doc.mustache +++ b/sdks/php/templates/model_doc.mustache @@ -1,12 +1,20 @@ # {{#models}}{{#model}}# {{classname}} +{{#useCustomTemplateCode}} {{unescapedDescription}} +{{/useCustomTemplateCode}} ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +{{^useCustomTemplateCode}} +{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{{dataType}}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} |{{^required}} [optional]{{/required}}{{#isReadOnly}} [readonly]{{/isReadOnly}}{{#defaultValue}} [default to {{{.}}}]{{/defaultValue}} +{{/vars}} +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} {{#vars}}| `{{name}}`{{#required}}*_required_{{/required}} | {{#isPrimitiveType}}```{{{dataType}}}```{{/isPrimitiveType}}{{^isPrimitiveType}}[```{{{dataType}}}```]({{complexType}}.md){{/isPrimitiveType}} | REPLACE_ME_WITH_DESCRIPTION_BEGIN {{unescapedDescription}} REPLACE_ME_WITH_DESCRIPTION_END | {{#isReadOnly}} [readonly]{{/isReadOnly}}{{#defaultValue}} [default to {{{.}}}]{{/defaultValue}} | {{/vars}} +{{/useCustomTemplateCode}} [[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md){{/model}}{{/models}} diff --git a/sdks/php/templates/model_enum.mustache b/sdks/php/templates/model_enum.mustache index 88036f76f..77001f2e6 100644 --- a/sdks/php/templates/model_enum.mustache +++ b/sdks/php/templates/model_enum.mustache @@ -5,7 +5,7 @@ class {{classname}} */ {{#allowableValues}} {{#enumVars}} - const {{^isString}}NUMBER_{{/isString}}{{{name}}} = {{{value}}}; + public const {{^isString}}NUMBER_{{/isString}}{{{name}}} = {{{value}}}; {{/enumVars}} {{/allowableValues}} diff --git a/sdks/php/templates/model_generic.mustache b/sdks/php/templates/model_generic.mustache index 240156c2d..3b213dd3b 100644 --- a/sdks/php/templates/model_generic.mustache +++ b/sdks/php/templates/model_generic.mustache @@ -1,4 +1,4 @@ -{{#vendorExtensions.x-base-class}}abstract {{/vendorExtensions.x-base-class}}class {{classname}} {{#parentSchema}}extends {{{parent}}}{{/parentSchema}}{{^parentSchema}}implements ModelInterface, ArrayAccess, \JsonSerializable{{/parentSchema}} +class {{classname}} {{#parentSchema}}extends {{{parent}}}{{/parentSchema}}{{^parentSchema}}implements ModelInterface, ArrayAccess, \JsonSerializable{{/parentSchema}} { public const DISCRIMINATOR = {{#discriminator}}'{{discriminatorName}}'{{/discriminator}}{{^discriminator}}null{{/discriminator}}; @@ -31,6 +31,23 @@ {{/-last}}{{/vars}} ]; + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + {{#vars}}'{{name}}' => {{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}}{{^-last}}, + {{/-last}}{{/vars}} + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + /** * Array of property to type mappings. Used for (de)serialization * @@ -51,6 +68,58 @@ return self::$openAPIFormats{{#parentSchema}} + parent::openAPIFormats(){{/parentSchema}}; } + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables{{#parentSchema}} + parent::openAPINullables(){{/parentSchema}}; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + /** * Array of attributes where the key is the local name, * and the value is the original name @@ -127,7 +196,7 @@ {{#isEnum}} {{#allowableValues}} {{#enumVars}} - const {{enumName}}_{{{name}}} = {{{value}}}; + public const {{enumName}}_{{{name}}} = {{{value}}}; {{/enumVars}} {{/allowableValues}} {{/isEnum}} @@ -154,7 +223,7 @@ /** * Associative array for storing property values * - * @var array + * @var mixed[] */ protected $container = []; {{/parentSchema}} @@ -162,7 +231,7 @@ /** * Constructor * - * @param array|null $data Associated array of property values + * @param mixed[] $data Associated array of property values * initializing the model */ public function __construct(array $data = null) @@ -172,7 +241,7 @@ {{/parentSchema}} {{#vars}} - $this->container['{{name}}'] = $data['{{name}}'] ?? {{{defaultValue}}}{{^defaultValue}}null{{/defaultValue}}; + $this->setIfExists('{{name}}', $data ?? [], {{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}); {{/vars}} {{#discriminator}} @@ -181,6 +250,7 @@ {{/discriminator}} } +{{#useCustomTemplateCode}} {{^discriminator}} /** @deprecated use ::init() */ public static function fromArray(array $data): {{classname}} @@ -191,7 +261,7 @@ /** Attempt to instantiate and hydrate a new instance of this class */ public static function init(array $data): {{classname}} { - /** @var {{classname}} $obj */ + /** @var {{classname}} */ $obj = ObjectSerializer::deserialize( $data, {{classname}}::class, @@ -217,7 +287,30 @@ return null; } {{/discriminator}} +{{/useCustomTemplateCode}} + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields +{{^useCustomTemplateCode}} + * @param mixed $defaultValue +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} +* @param string|int|object|array|mixed $defaultValue +{{/useCustomTemplateCode}} + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } /** * Show all the invalid properties with reasons. @@ -316,7 +409,7 @@ /** * Gets {{name}} * - * @return {{#vendorExtensions.x-int-or-string}}int|string{{/vendorExtensions.x-int-or-string}}{{^vendorExtensions.x-int-or-string}}{{{dataType}}}{{/vendorExtensions.x-int-or-string}}{{^required}}|null{{/required}} + * @return {{{dataType}}}{{^required}}|null{{/required}} {{#deprecated}} * @deprecated {{/deprecated}} @@ -329,7 +422,7 @@ /** * Sets {{name}} * - * @param {{#vendorExtensions.x-int-or-string}}int|string{{/vendorExtensions.x-int-or-string}}{{^vendorExtensions.x-int-or-string}}{{{dataType}}}{{/vendorExtensions.x-int-or-string}}{{^required}}|null{{/required}} ${{name}}{{#description}} {{{.}}}{{/description}}{{^description}} {{{name}}}{{/description}} + * @param {{{dataType}}}{{^required}}|null{{/required}} ${{name}}{{#description}} {{{.}}}{{/description}}{{^description}} {{{name}}}{{/description}} * * @return self {{#deprecated}} @@ -338,10 +431,27 @@ */ public function {{setter}}(${{name}}) { + {{#isNullable}} + if (is_null(${{name}})) { + array_push($this->openAPINullablesSetToNull, '{{name}}'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('{{name}}', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + {{/isNullable}} + {{^isNullable}} + if (is_null(${{name}})) { + throw new \InvalidArgumentException('non-nullable {{name}} cannot be null'); + } + {{/isNullable}} {{#isEnum}} $allowedValues = $this->{{getter}}AllowableValues(); {{^isContainer}} - if ({{^required}}!is_null(${{name}}) && {{/required}}!in_array(${{{name}}}, $allowedValues, true)) { + if ({{#isNullable}}!is_null(${{name}}) && {{/isNullable}}!in_array(${{{name}}}, $allowedValues, true)) { throw new \InvalidArgumentException( sprintf( "Invalid value '%s' for '{{name}}', must be one of '%s'", @@ -352,7 +462,7 @@ } {{/isContainer}} {{#isContainer}} - if ({{^required}}!is_null(${{name}}) && {{/required}}array_diff(${{{name}}}, $allowedValues)) { + if ({{#isNullable}}!is_null(${{name}}) && {{/isNullable}}array_diff(${{{name}}}, $allowedValues)) { throw new \InvalidArgumentException( sprintf( "Invalid value for '{{name}}', must be one of '%s'", @@ -364,35 +474,35 @@ {{/isEnum}} {{#hasValidation}} {{#maxLength}} - if ({{^required}}!is_null(${{name}}) && {{/required}}(mb_strlen(${{name}}) > {{maxLength}})) { + if ({{#isNullable}}!is_null(${{name}}) && {{/isNullable}}(mb_strlen(${{name}}) > {{maxLength}})) { throw new \InvalidArgumentException('invalid length for ${{name}} when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maxLength}}.'); }{{/maxLength}} {{#minLength}} - if ({{^required}}!is_null(${{name}}) && {{/required}}(mb_strlen(${{name}}) < {{minLength}})) { + if ({{#isNullable}}!is_null(${{name}}) && {{/isNullable}}(mb_strlen(${{name}}) < {{minLength}})) { throw new \InvalidArgumentException('invalid length for ${{name}} when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minLength}}.'); } {{/minLength}} {{#maximum}} - if ({{^required}}!is_null(${{name}}) && {{/required}}(${{name}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}})) { + if ({{#isNullable}}!is_null(${{name}}) && {{/isNullable}}(${{name}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}})) { throw new \InvalidArgumentException('invalid value for ${{name}} when calling {{classname}}.{{operationId}}, must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{maximum}}.'); } {{/maximum}} {{#minimum}} - if ({{^required}}!is_null(${{name}}) && {{/required}}(${{name}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}})) { + if ({{#isNullable}}!is_null(${{name}}) && {{/isNullable}}(${{name}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}})) { throw new \InvalidArgumentException('invalid value for ${{name}} when calling {{classname}}.{{operationId}}, must be bigger than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{minimum}}.'); } {{/minimum}} {{#pattern}} - if ({{^required}}!is_null(${{name}}) && {{/required}}(!preg_match("{{{pattern}}}", ${{name}}))) { - throw new \InvalidArgumentException("invalid value for ${{name}} when calling {{classname}}.{{operationId}}, must conform to the pattern {{{pattern}}}."); + if ({{#isNullable}}!is_null(${{name}}) && {{/isNullable}}(!preg_match("{{{pattern}}}", ObjectSerializer::toString(${{name}})))) { + throw new \InvalidArgumentException("invalid value for \${{name}} when calling {{classname}}.{{operationId}}, must conform to the pattern {{{pattern}}}."); } {{/pattern}} {{#maxItems}} - if ({{^required}}!is_null(${{name}}) && {{/required}}(count(${{name}}) > {{maxItems}})) { + if ({{#isNullable}}!is_null(${{name}}) && {{/isNullable}}(count(${{name}}) > {{maxItems}})) { throw new \InvalidArgumentException('invalid value for ${{name}} when calling {{classname}}.{{operationId}}, number of items must be less than or equal to {{maxItems}}.'); }{{/maxItems}} {{#minItems}} - if ({{^required}}!is_null(${{name}}) && {{/required}}(count(${{name}}) < {{minItems}})) { + if ({{#isNullable}}!is_null(${{name}}) && {{/isNullable}}(count(${{name}}) < {{minItems}})) { throw new \InvalidArgumentException('invalid length for ${{name}} when calling {{classname}}.{{operationId}}, number of items must be greater than or equal to {{minItems}}.'); } {{/minItems}} @@ -405,12 +515,14 @@ /** * Returns true if offset exists. False otherwise. * - * @param mixed $offset Offset + * @param integer $offset Offset * * @return boolean */ - #[ReturnTypeWillChange] - public function offsetExists($offset) +{{#useCustomTemplateCode}} + #[\ReturnTypeWillChange] +{{/useCustomTemplateCode}} + public function offsetExists($offset): bool { return isset($this->container[$offset]); } @@ -418,11 +530,11 @@ /** * Gets offset. * - * @param mixed $offset Offset + * @param integer $offset Offset * * @return mixed|null */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->container[$offset] ?? null; @@ -431,13 +543,15 @@ /** * Sets value based on offset. * - * @param mixed $offset Offset + * @param int|null $offset Offset * @param mixed $value Value to be set * * @return void */ - #[ReturnTypeWillChange] - public function offsetSet($offset, $value) +{{#useCustomTemplateCode}} + #[\ReturnTypeWillChange] +{{/useCustomTemplateCode}} + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; @@ -449,12 +563,14 @@ /** * Unsets offset. * - * @param mixed $offset Offset + * @param integer $offset Offset * * @return void */ - #[ReturnTypeWillChange] - public function offsetUnset($offset) +{{#useCustomTemplateCode}} + #[\ReturnTypeWillChange] +{{/useCustomTemplateCode}} + public function offsetUnset($offset): void { unset($this->container[$offset]); } @@ -463,10 +579,10 @@ * Serializes the object to a value that can be serialized natively by json_encode(). * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php * - * @return scalar|object|array|null Returns data which can be serialized by json_encode(), which is a value + * @return mixed Returns data which can be serialized by json_encode(), which is a value * of any type other than a resource. */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function jsonSerialize() { return ObjectSerializer::sanitizeForSerialization($this); @@ -481,7 +597,12 @@ { return json_encode( ObjectSerializer::sanitizeForSerialization($this), +{{^useCustomTemplateCode}} + JSON_PRETTY_PRINT +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} JSON_UNESCAPED_SLASHES +{{/useCustomTemplateCode}} ); } diff --git a/sdks/php/templates/model_test.mustache b/sdks/php/templates/model_test.mustache index c1b70a6fb..f1c46499b 100644 --- a/sdks/php/templates/model_test.mustache +++ b/sdks/php/templates/model_test.mustache @@ -4,7 +4,7 @@ /** * {{classname}}Test * - * PHP version {{phpVersion}} + * PHP version 7.4 * * @category Class * @package {{invokerPackage}} @@ -69,17 +69,17 @@ class {{classname}}Test extends TestCase public function test{{classname}}() { // TODO: implement - $this->markTestIncomplete('Not implemented'); + self::markTestIncomplete('Not implemented'); } {{#vars}} /** * Test attribute "{{name}}" */ - public function testProperty{{nameInCamelCase}}() + public function testProperty{{nameInPascalCase}}() { // TODO: implement - $this->markTestIncomplete('Not implemented'); + self::markTestIncomplete('Not implemented'); } {{/vars}} } diff --git a/sdks/php/templates/partial_header.mustache b/sdks/php/templates/partial_header.mustache index ef3530aae..bc1b11e29 100644 --- a/sdks/php/templates/partial_header.mustache +++ b/sdks/php/templates/partial_header.mustache @@ -14,5 +14,5 @@ * Contact: {{{.}}} {{/infoEmail}} * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: {{{generatorVersion}}} + * Generator version: {{{generatorVersion}}} */ diff --git a/sdks/php/templates/php_doc_auth_partial.mustache b/sdks/php/templates/php_doc_auth_partial.mustache index 6b03e0d09..5f2d05eaf 100644 --- a/sdks/php/templates/php_doc_auth_partial.mustache +++ b/sdks/php/templates/php_doc_auth_partial.mustache @@ -3,7 +3,13 @@ {{#isBasicBasic}} // Configure HTTP basic authorization: {{{name}}} $config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration() +{{^useCustomTemplateCode}} + ->setUsername('YOUR_USERNAME') + ->setPassword('YOUR_PASSWORD'); +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} ->setApiKey('YOUR_API_KEY'); +{{/useCustomTemplateCode}} {{/isBasicBasic}} {{#isBasicBearer}} // Configure Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} authorization: {{{name}}} @@ -13,6 +19,10 @@ $config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setAcce {{#isApiKey}} // Configure API key authorization: {{{name}}} $config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setApiKey('{{{keyParamName}}}', 'YOUR_API_KEY'); +{{^useCustomTemplateCode}} +// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +// $config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setApiKeyPrefix('{{{keyParamName}}}', 'Bearer'); +{{/useCustomTemplateCode}} {{/isApiKey}} {{#isOAuth}} // Configure OAuth2 access token for authorization: {{{name}}} diff --git a/sdks/php/templates/phpunit.xml.mustache b/sdks/php/templates/phpunit.xml.mustache index b72fb7c6e..7f1126c45 100644 --- a/sdks/php/templates/phpunit.xml.mustache +++ b/sdks/php/templates/phpunit.xml.mustache @@ -2,14 +2,19 @@ - {{apiSrcPath}} - {{modelSrcPath}} + {{#lambda.forwardslash}}{{apiSrcPath}}{{/lambda.forwardslash}} + {{#lambda.forwardslash}}{{modelSrcPath}}{{/lambda.forwardslash}} +{{^useCustomTemplateCode}} {{apiTestPath}} {{modelTestPath}} +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} + ./test +{{/useCustomTemplateCode}} diff --git a/sdks/php/test/ObjectSerializerTest.php b/sdks/php/test/ObjectSerializerTest.php index 2b27a769e..3f548863d 100644 --- a/sdks/php/test/ObjectSerializerTest.php +++ b/sdks/php/test/ObjectSerializerTest.php @@ -122,4 +122,73 @@ public function testValuesJsonified() $this->assertEquals($expectedOauth, $result['oauth']); } + + public function testExplicitIndexKeysAreKeptForNestedValues(): void + { + $data = [ + 'type' => 'request_signature', + 'subject' => 'unclaimed draft that should work', + 'message' => 'indeed', + 'metadata' => null, + 'test_mode' => false, + 'signers' => [ + '1' => [ + 'order' => 1, + 'email_address' => 'john@example.com', + 'name' => 'John Q Public', + ], + ], + 'form_fields_per_document' => [ + [ + 'document_index' => 0, + 'name' => null, + 'type' => 'signature', + 'x' => 530, + 'y' => 415, + 'width' => 120, + 'height' => 30, + 'required' => true, + 'signer' => 1, + ], + ], + 'client_id' => '1df877123c9b64884c86530a1c1d309d', + 'requester_email_address' => 'test-1725033846-d0e693477a@example.com', + ]; + + $obj = Model\UnclaimedDraftCreateEmbeddedRequest::init($data); + + $expected_signer_key = '1'; + $this->assertArrayHasKey($expected_signer_key, $obj->getSigners()); + $this->assertEquals( + $data['signers'][$expected_signer_key]['email_address'], + $obj->getSigners()[$expected_signer_key]->getEmailAddress(), + ); + + $expected_ffpd_key = 0; + $this->assertArrayHasKey($expected_ffpd_key, $obj->getFormFieldsPerDocument()); + $this->assertEquals( + $data['form_fields_per_document'][$expected_ffpd_key]['type'], + $obj->getFormFieldsPerDocument()[$expected_ffpd_key]->getType(), + ); + } + + public function testSplFileObjectUntouched(): void + { + $requestClass = Model\SignatureRequestSendRequest::class; + $requestData = TestUtils::getFixtureData($requestClass)['default']; + unset($requestData['file_urls']); + + $filename = 'pdf-sample.pdf'; + $filepath = self::ROOT_FILE_PATH . "/{$filename}"; + + $requestData['files'] = [new SplFileObject($filepath)]; + + $obj = Model\SignatureRequestSendRequest::init($requestData); + + $file = $obj->getFiles()[0]; + + $this->assertInstanceOf(SplFileObject::class, $file); + $this->assertEquals($filename, $file->getFilename()); + $this->assertEquals($filepath, $file->getPathname()); + } }