diff --git a/gen/openapi.json b/gen/openapi.json index 2ff4d8a..424f29e 100644 --- a/gen/openapi.json +++ b/gen/openapi.json @@ -2,7 +2,7 @@ "openapi": "3.0.1", "info": { "title": "Commerce Layer Provisioning API", - "version": "1.0.5", + "version": "1.0.6", "contact": { "name": "API Support", "url": "https://commercelayer.io", @@ -483,6 +483,183 @@ } } }, + "/identity_providers": { + "post": { + "operationId": "POST/identity_providers", + "summary": "Creates an identity provider", + "description": "Creates an identity provider", + "tags": [ + "identity_providers" + ], + "requestBody": { + "required": true, + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/identityProviderCreate" + } + } + } + }, + "responses": { + "201": { + "description": "The created identity provider object", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/identityProviderResponse" + } + } + } + } + } + }, + "get": { + "operationId": "GET/identity_providers", + "summary": "List all identity providers", + "description": "List all identity providers", + "tags": [ + "identity_providers" + ], + "responses": { + "200": { + "description": "A list of identity provider objects", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/identityProviderResponseList" + } + } + } + } + } + } + }, + "/identity_providers/{identityProviderId}": { + "get": { + "operationId": "GET/identity_providers/identityProviderId", + "summary": "Retrieve an identity provider", + "description": "Retrieve an identity provider", + "parameters": [ + { + "name": "identityProviderId", + "in": "path", + "schema": { + "type": "string" + }, + "required": true, + "description": "The resource's id" + } + ], + "tags": [ + "identity_providers" + ], + "responses": { + "200": { + "description": "The identity provider object", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/identityProviderResponse" + } + } + } + } + } + }, + "patch": { + "operationId": "PATCH/identity_providers/identityProviderId", + "summary": "Updates an identity provider", + "description": "Updates an identity provider", + "tags": [ + "identity_providers" + ], + "parameters": [ + { + "name": "identityProviderId", + "in": "path", + "schema": { + "type": "string" + }, + "required": true, + "description": "The resource's id" + } + ], + "requestBody": { + "required": true, + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/identityProviderUpdate" + } + } + } + }, + "responses": { + "200": { + "description": "The updated identity provider object", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/identityProviderResponse" + } + } + } + } + } + }, + "delete": { + "operationId": "DELETE/identity_providers/identityProviderId", + "summary": "Delete an identity provider", + "description": "Delete an identity provider", + "tags": [ + "identity_providers" + ], + "parameters": [ + { + "name": "identityProviderId", + "in": "path", + "schema": { + "type": "string" + }, + "required": true, + "description": "The resource's id" + } + ], + "responses": { + "204": { + "description": "No content" + } + } + } + }, + "/identity_providers/{identityProviderId}/user": { + "get": { + "operationId": "GET/identityProviderId/user", + "summary": "Related identity provider", + "description": "Related identity provider", + "tags": [ + "user", + "has_one" + ], + "parameters": [ + { + "name": "identityProviderId", + "in": "path", + "schema": { + "type": "string" + }, + "required": true, + "description": "The resource's id" + } + ], + "responses": { + "200": { + "description": "The user associated to the identity provider" + } + } + } + }, "/memberships": { "post": { "operationId": "POST/memberships", @@ -1607,6 +1784,33 @@ } } }, + "/user/{userId}/identity_providers": { + "get": { + "operationId": "GET/userId/identity_providers", + "summary": "Related user", + "description": "Related user", + "tags": [ + "identity_providers", + "has_many" + ], + "parameters": [ + { + "name": "userId", + "in": "path", + "schema": { + "type": "string" + }, + "required": true, + "description": "The resource's id" + } + ], + "responses": { + "200": { + "description": "The identity_providers associated to the user" + } + } + } + }, "/versions": { "get": { "operationId": "GET/versions", @@ -2584,39 +2788,627 @@ }, "relationships": { "type": "object", - "properties": { - "role": { - "required": [ - "data" - ], - "type": "object", - "properties": { - "data": { - "type": "object", - "properties": { - "type": { - "type": "string", - "description": "The resource's type", - "enum": [ - "roles" - ] - }, - "id": { - "type": "string", - "description": "The resource's id", - "example": "XGZwpOSrWL" - } - } - } - } - } - } + "properties": { + "role": { + "required": [ + "data" + ], + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "The resource's type", + "enum": [ + "roles" + ] + }, + "id": { + "type": "string", + "description": "The resource's id", + "example": "XGZwpOSrWL" + } + } + } + } + } + } + } + } + } + } + }, + "applicationMembershipResponse": { + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The resource's id", + "example": "XGZwpOSrWL" + }, + "type": { + "type": "string", + "description": "The resource's type", + "enum": [ + "application_memberships" + ] + }, + "links": { + "type": "object", + "properties": { + "self": { + "type": "string", + "description": "URL" + } + } + }, + "attributes": { + "$ref": "#/components/schemas/applicationMembership/properties/data/properties/attributes" + }, + "relationships": { + "type": "object", + "properties": { + "api_credential": { + "type": "object", + "properties": { + "links": { + "type": "object", + "properties": { + "self": { + "type": "string", + "description": "URL" + }, + "related": { + "type": "string", + "description": "URL" + } + } + }, + "data": { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "The resource's type", + "enum": [ + "api_credential" + ] + }, + "id": { + "type": "string", + "description": "The resource ID" + } + } + } + } + }, + "membership": { + "type": "object", + "properties": { + "links": { + "type": "object", + "properties": { + "self": { + "type": "string", + "description": "URL" + }, + "related": { + "type": "string", + "description": "URL" + } + } + }, + "data": { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "The resource's type", + "enum": [ + "membership" + ] + }, + "id": { + "type": "string", + "description": "The resource ID" + } + } + } + } + }, + "organization": { + "type": "object", + "properties": { + "links": { + "type": "object", + "properties": { + "self": { + "type": "string", + "description": "URL" + }, + "related": { + "type": "string", + "description": "URL" + } + } + }, + "data": { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "The resource's type", + "enum": [ + "organization" + ] + }, + "id": { + "type": "string", + "description": "The resource ID" + } + } + } + } + }, + "role": { + "type": "object", + "properties": { + "links": { + "type": "object", + "properties": { + "self": { + "type": "string", + "description": "URL" + }, + "related": { + "type": "string", + "description": "URL" + } + } + }, + "data": { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "The resource's type", + "enum": [ + "role" + ] + }, + "id": { + "type": "string", + "description": "The resource ID" + } + } + } + } + } + } + } + } + } + } + }, + "applicationMembershipResponseList": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/applicationMembershipResponse/properties/data" + } + } + } + }, + "identityProvider": { + "type": "object", + "properties": { + "data": { + "type": "object", + "required": [ + "type", + "attributes" + ], + "properties": { + "type": { + "type": "string", + "description": "The resource's type", + "enum": [ + "identity_providers" + ] + }, + "attributes": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "The name of the Identity provider.", + "example": "Org auth0", + "nullable": false + }, + "client_id": { + "type": "string", + "description": "The client ID used for the auth workflow.", + "example": "a6CDk5v1ZV99GrtOcfYVEZRnDDt", + "nullable": false + }, + "client_secret": { + "type": "string", + "description": "The client secret used for the auth workflow.", + "example": "s6CD55v1ZV99ArtOcfYVEZRnDDf", + "nullable": false + }, + "issuer": { + "type": "string", + "description": "The issuer used for the auth workflow.", + "example": "https://dev.auth987.com/", + "nullable": false + }, + "status": { + "type": "string", + "description": "The identity provider status. One of `pending` (default), `verified` or `error`.", + "example": "pending", + "readOnly": true, + "enum": [ + "pending", + "verified", + "error" + ] + }, + "domains": { + "type": "string", + "description": "The list of domains in scope (comma-separated).", + "example": "dev.auth987.com,stg.auth987.com", + "nullable": false + }, + "token_url": { + "type": "string", + "description": "The token URL used for the auth workflow.", + "example": "https://dev.auth987.com/oauth/token", + "nullable": false + }, + "authorize_url": { + "type": "string", + "description": "The authorize URL used for the auth workflow.", + "example": "https://dev.auth987.com/authorize", + "nullable": false + }, + "jwks_url": { + "type": "string", + "description": "The JWKS key store URL used for the auth workflow.", + "example": "https://dev.auth987.com/.well-known/jwks.json", + "nullable": false + }, + "txt_record": { + "type": "string", + "description": "The TXT record value used to check the domain.", + "example": "cl-verification=a6CDk5v", + "readOnly": true + }, + "organization": { + "type": "string", + "description": "The organization identifier for authorize params.", + "example": "org_76gsfs5gd", + "nullable": true + }, + "created_at": { + "type": "string", + "description": "Time at which the resource was created.", + "example": "2018-01-01T12:00:00.000Z", + "readOnly": true + }, + "updated_at": { + "type": "string", + "description": "Time at which the resource was last updated.", + "example": "2018-01-01T12:00:00.000Z", + "readOnly": true + }, + "reference": { + "type": "string", + "description": "A string that you can use to add any external identifier to the resource. This can be useful for integrating the resource to an external system, like an ERP, a marketing tool, a CRM, or whatever.", + "example": "ANY-EXTERNAL-REFEFERNCE", + "nullable": true + }, + "reference_origin": { + "type": "string", + "description": "Any identifier of the third party system that defines the reference code.", + "example": "ANY-EXTERNAL-REFEFERNCE-ORIGIN", + "nullable": true + }, + "metadata": { + "type": "object", + "description": "Set of key-value pairs that you can attach to the resource. This can be useful for storing additional information about the resource in a structured format.", + "example": { + "foo": "bar" + }, + "nullable": true + }, + "disabled_at": { + "type": "string", + "description": "Time at which this resource was disabled.", + "example": "2018-01-01T12:00:00.000Z", + "readOnly": true + } + } + }, + "relationships": { + "type": "object", + "properties": { + "user": { + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "The resource's type", + "enum": [ + "user" + ] + }, + "id": { + "type": "string", + "description": "The resource's id", + "example": "XGZwpOSrWL" + } + } + } + } + } + } + } + } + } + } + }, + "identityProviderCreate": { + "required": [ + "data" + ], + "type": "object", + "properties": { + "data": { + "type": "object", + "required": [ + "type", + "attributes" + ], + "properties": { + "type": { + "type": "string", + "description": "The resource's type", + "enum": [ + "identity_providers" + ] + }, + "attributes": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "The name of the Identity provider.", + "example": "Org auth0" + }, + "client_id": { + "type": "string", + "description": "The client ID used for the auth workflow.", + "example": "a6CDk5v1ZV99GrtOcfYVEZRnDDt" + }, + "client_secret": { + "type": "string", + "description": "The client secret used for the auth workflow.", + "example": "s6CD55v1ZV99ArtOcfYVEZRnDDf" + }, + "issuer": { + "type": "string", + "description": "The issuer used for the auth workflow.", + "example": "https://dev.auth987.com/" + }, + "domains": { + "type": "string", + "description": "The list of domains in scope (comma-separated).", + "example": "dev.auth987.com,stg.auth987.com" + }, + "token_url": { + "type": "string", + "description": "The token URL used for the auth workflow.", + "example": "https://dev.auth987.com/oauth/token" + }, + "authorize_url": { + "type": "string", + "description": "The authorize URL used for the auth workflow.", + "example": "https://dev.auth987.com/authorize" + }, + "jwks_url": { + "type": "string", + "description": "The JWKS key store URL used for the auth workflow.", + "example": "https://dev.auth987.com/.well-known/jwks.json" + }, + "organization": { + "type": "string", + "description": "The organization identifier for authorize params.", + "example": "org_76gsfs5gd" + }, + "reference": { + "type": "string", + "description": "A string that you can use to add any external identifier to the resource. This can be useful for integrating the resource to an external system, like an ERP, a marketing tool, a CRM, or whatever.", + "example": "ANY-EXTERNAL-REFEFERNCE" + }, + "reference_origin": { + "type": "string", + "description": "Any identifier of the third party system that defines the reference code.", + "example": "ANY-EXTERNAL-REFEFERNCE-ORIGIN" + }, + "metadata": { + "type": "object", + "description": "Set of key-value pairs that you can attach to the resource. This can be useful for storing additional information about the resource in a structured format.", + "example": { + "foo": "bar" + } + }, + "_disable": { + "type": "boolean", + "description": "Send this attribute if you want to mark this resource as disabled.", + "example": true + }, + "_enable": { + "type": "boolean", + "description": "Send this attribute if you want to mark this resource as enabled.", + "example": true + } + }, + "required": [ + "name", + "client_id", + "client_secret", + "issuer", + "domains", + "token_url", + "authorize_url", + "jwks_url" + ] + }, + "relationships": { + "type": "object", + "properties": {} + } + } + } + } + }, + "identityProviderUpdate": { + "required": [ + "data" + ], + "type": "object", + "properties": { + "data": { + "type": "object", + "required": [ + "type", + "id", + "attributes" + ], + "properties": { + "type": { + "type": "string", + "description": "The resource's type", + "enum": [ + "identity_providers" + ] + }, + "id": { + "type": "string", + "description": "The resource's id", + "example": "XGZwpOSrWL" + }, + "attributes": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "The name of the Identity provider.", + "example": "Org auth0", + "nullable": false + }, + "client_id": { + "type": "string", + "description": "The client ID used for the auth workflow.", + "example": "a6CDk5v1ZV99GrtOcfYVEZRnDDt", + "nullable": false + }, + "client_secret": { + "type": "string", + "description": "The client secret used for the auth workflow.", + "example": "s6CD55v1ZV99ArtOcfYVEZRnDDf", + "nullable": false + }, + "issuer": { + "type": "string", + "description": "The issuer used for the auth workflow.", + "example": "https://dev.auth987.com/", + "nullable": false + }, + "domains": { + "type": "string", + "description": "The list of domains in scope (comma-separated).", + "example": "dev.auth987.com,stg.auth987.com", + "nullable": false + }, + "token_url": { + "type": "string", + "description": "The token URL used for the auth workflow.", + "example": "https://dev.auth987.com/oauth/token", + "nullable": false + }, + "authorize_url": { + "type": "string", + "description": "The authorize URL used for the auth workflow.", + "example": "https://dev.auth987.com/authorize", + "nullable": false + }, + "jwks_url": { + "type": "string", + "description": "The JWKS key store URL used for the auth workflow.", + "example": "https://dev.auth987.com/.well-known/jwks.json", + "nullable": false + }, + "organization": { + "type": "string", + "description": "The organization identifier for authorize params.", + "example": "org_76gsfs5gd", + "nullable": true + }, + "reference": { + "type": "string", + "description": "A string that you can use to add any external identifier to the resource. This can be useful for integrating the resource to an external system, like an ERP, a marketing tool, a CRM, or whatever.", + "example": "ANY-EXTERNAL-REFEFERNCE", + "nullable": true + }, + "reference_origin": { + "type": "string", + "description": "Any identifier of the third party system that defines the reference code.", + "example": "ANY-EXTERNAL-REFEFERNCE-ORIGIN", + "nullable": true + }, + "metadata": { + "type": "object", + "description": "Set of key-value pairs that you can attach to the resource. This can be useful for storing additional information about the resource in a structured format.", + "example": { + "foo": "bar" + }, + "nullable": true + }, + "_disable": { + "type": "boolean", + "description": "Send this attribute if you want to mark this resource as disabled.", + "example": true, + "nullable": false + }, + "_enable": { + "type": "boolean", + "description": "Send this attribute if you want to mark this resource as enabled.", + "example": true, + "nullable": false + } + } + }, + "relationships": { + "type": "object", + "properties": {} } } } } }, - "applicationMembershipResponse": { + "identityProviderResponse": { "type": "object", "properties": { "data": { @@ -2631,7 +3423,7 @@ "type": "string", "description": "The resource's type", "enum": [ - "application_memberships" + "identity_providers" ] }, "links": { @@ -2644,114 +3436,12 @@ } }, "attributes": { - "$ref": "#/components/schemas/applicationMembership/properties/data/properties/attributes" + "$ref": "#/components/schemas/identityProvider/properties/data/properties/attributes" }, "relationships": { "type": "object", "properties": { - "api_credential": { - "type": "object", - "properties": { - "links": { - "type": "object", - "properties": { - "self": { - "type": "string", - "description": "URL" - }, - "related": { - "type": "string", - "description": "URL" - } - } - }, - "data": { - "type": "object", - "properties": { - "type": { - "type": "string", - "description": "The resource's type", - "enum": [ - "api_credential" - ] - }, - "id": { - "type": "string", - "description": "The resource ID" - } - } - } - } - }, - "membership": { - "type": "object", - "properties": { - "links": { - "type": "object", - "properties": { - "self": { - "type": "string", - "description": "URL" - }, - "related": { - "type": "string", - "description": "URL" - } - } - }, - "data": { - "type": "object", - "properties": { - "type": { - "type": "string", - "description": "The resource's type", - "enum": [ - "membership" - ] - }, - "id": { - "type": "string", - "description": "The resource ID" - } - } - } - } - }, - "organization": { - "type": "object", - "properties": { - "links": { - "type": "object", - "properties": { - "self": { - "type": "string", - "description": "URL" - }, - "related": { - "type": "string", - "description": "URL" - } - } - }, - "data": { - "type": "object", - "properties": { - "type": { - "type": "string", - "description": "The resource's type", - "enum": [ - "organization" - ] - }, - "id": { - "type": "string", - "description": "The resource ID" - } - } - } - } - }, - "role": { + "user": { "type": "object", "properties": { "links": { @@ -2774,7 +3464,7 @@ "type": "string", "description": "The resource's type", "enum": [ - "role" + "user" ] }, "id": { @@ -2791,13 +3481,13 @@ } } }, - "applicationMembershipResponseList": { + "identityProviderResponseList": { "type": "object", "properties": { "data": { "type": "array", "items": { - "$ref": "#/components/schemas/applicationMembershipResponse/properties/data" + "$ref": "#/components/schemas/identityProviderResponse/properties/data" } } } @@ -3661,6 +4351,18 @@ "example": false, "readOnly": true }, + "api_new_auth": { + "type": "boolean", + "description": "Forces the usage of the new Authentication API.", + "example": true, + "readOnly": true + }, + "api_purge_single_resource": { + "type": "boolean", + "description": "Enables the purge of cached single resources when list is purged.", + "example": false, + "readOnly": true + }, "addresses_phone_required": { "type": "boolean", "description": "Indicates if the phone attribute is required for addresses, default is true.", @@ -3745,6 +4447,12 @@ "example": 10, "readOnly": true }, + "imports_purge_cache": { + "type": "boolean", + "description": "Enables purging of cached resources upon succeeded imports.", + "example": true, + "readOnly": true + }, "promotions_max_concurrent_count": { "type": "integer", "description": "The maximum number of active concurrent promotions allowed for your organization, default is 10.", @@ -3757,6 +4465,18 @@ "example": 0, "readOnly": true }, + "discount_engines_enabled": { + "type": "boolean", + "description": "Enables the use of an external discount engine in place of the standard one, default is false.", + "example": false, + "readOnly": true + }, + "discount_engines_errors": { + "type": "boolean", + "description": "Enables raising of API errors in case of discount engine failure, default is false.", + "example": false, + "readOnly": true + }, "tax_calculators_errors": { "type": "boolean", "description": "Enables raising of API errors in case of tax calculation failure, default is false.", @@ -5677,7 +6397,30 @@ }, "relationships": { "type": "object", - "properties": {} + "properties": { + "identity_providers": { + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "The resource's type", + "enum": [ + "identity_providers" + ] + }, + "id": { + "type": "string", + "description": "The resource's id", + "example": "XGZwpOSrWL" + } + } + } + } + } + } } } } @@ -5693,7 +6436,6 @@ "type": "object", "required": [ "type", - "id", "attributes" ], "properties": { @@ -5704,11 +6446,6 @@ "user" ] }, - "id": { - "type": "string", - "description": "The resource's id", - "example": "XGZwpOSrWL" - }, "attributes": { "type": "object", "properties": { @@ -5798,7 +6535,42 @@ }, "relationships": { "type": "object", - "properties": {} + "properties": { + "identity_providers": { + "type": "object", + "properties": { + "links": { + "type": "object", + "properties": { + "self": { + "type": "string", + "description": "URL" + }, + "related": { + "type": "string", + "description": "URL" + } + } + }, + "data": { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "The resource's type", + "enum": [ + "identity_providers" + ] + }, + "id": { + "type": "string", + "description": "The resource ID" + } + } + } + } + } + } } } } @@ -5993,6 +6765,10 @@ "name": "application_memberships", "description": "resource type" }, + { + "name": "identity_providers", + "description": "resource type" + }, { "name": "memberships", "description": "resource type" diff --git a/gen/resources.json b/gen/resources.json index a7fc320..2fbe24a 100644 --- a/gen/resources.json +++ b/gen/resources.json @@ -550,6 +550,303 @@ ] } }, + { + "id": "identity_provider", + "type": "resources", + "attributes": { + "singleton": false, + "deprecated": false, + "actions": [ + "create", + "list", + "retrieve", + "update", + "delete" + ], + "examples": {}, + "filter_scopes": [], + "fields": { + "name": { + "type": "string", + "desc": "The name of the Identity provider.", + "required": "required", + "creatable": true, + "updatable": true, + "fetchable": true, + "filterable": true, + "sortable": true, + "example": "Org auth0" + }, + "client_id": { + "type": "string", + "desc": "The client ID used for the auth workflow.", + "required": "required", + "creatable": true, + "updatable": true, + "fetchable": true, + "filterable": true, + "sortable": true, + "example": "a6CDk5v1ZV99GrtOcfYVEZRnDDt" + }, + "client_secret": { + "type": "string", + "desc": "The client secret used for the auth workflow.", + "required": "required", + "creatable": true, + "updatable": true, + "fetchable": true, + "filterable": true, + "sortable": true, + "example": "s6CD55v1ZV99ArtOcfYVEZRnDDf" + }, + "issuer": { + "type": "string", + "desc": "The issuer used for the auth workflow.", + "required": "required", + "creatable": true, + "updatable": true, + "fetchable": true, + "filterable": true, + "sortable": true, + "example": "https://dev.auth987.com/" + }, + "status": { + "type": "string", + "desc": "The identity provider status. One of `pending` (default), `verified` or `error`.", + "creatable": false, + "updatable": false, + "fetchable": true, + "filterable": true, + "sortable": true, + "example": "pending", + "enum": [ + "pending", + "verified", + "error" + ], + "aasm": true + }, + "domains": { + "type": "string", + "desc": "The list of domains in scope (comma-separated).", + "required": "required", + "creatable": true, + "updatable": true, + "fetchable": true, + "filterable": true, + "sortable": true, + "example": "dev.auth987.com,stg.auth987.com" + }, + "token_url": { + "type": "string", + "desc": "The token URL used for the auth workflow.", + "required": "required", + "creatable": true, + "updatable": true, + "fetchable": true, + "filterable": true, + "sortable": true, + "example": "https://dev.auth987.com/oauth/token" + }, + "authorize_url": { + "type": "string", + "desc": "The authorize URL used for the auth workflow.", + "required": "required", + "creatable": true, + "updatable": true, + "fetchable": true, + "filterable": true, + "sortable": true, + "example": "https://dev.auth987.com/authorize" + }, + "jwks_url": { + "type": "string", + "desc": "The JWKS key store URL used for the auth workflow.", + "required": "required", + "creatable": true, + "updatable": true, + "fetchable": true, + "filterable": true, + "sortable": true, + "example": "https://dev.auth987.com/.well-known/jwks.json" + }, + "txt_record": { + "type": "string", + "desc": "The TXT record value used to check the domain.", + "creatable": false, + "updatable": false, + "fetchable": true, + "filterable": true, + "sortable": true, + "example": "cl-verification=a6CDk5v" + }, + "organization": { + "type": "string", + "desc": "The organization identifier for authorize params.", + "creatable": true, + "updatable": true, + "fetchable": true, + "filterable": true, + "sortable": true, + "example": "org_76gsfs5gd" + }, + "id": { + "format": "id", + "type": "string", + "desc": "Unique identifier for the resource (hash).", + "required": "required", + "creatable": false, + "updatable": false, + "fetchable": true, + "filterable": true, + "sortable": true, + "example": "XAyRWNUzyN" + }, + "created_at": { + "type": "datetime", + "desc": "Time at which the resource was created.", + "required": "required", + "creatable": false, + "updatable": false, + "fetchable": true, + "filterable": true, + "sortable": true, + "example": "2018-01-01T12:00:00.000Z" + }, + "updated_at": { + "type": "datetime", + "desc": "Time at which the resource was last updated.", + "required": "required", + "creatable": false, + "updatable": false, + "fetchable": true, + "filterable": true, + "sortable": true, + "example": "2018-01-01T12:00:00.000Z" + }, + "reference": { + "type": "string", + "desc": "A string that you can use to add any external identifier to the resource. This can be useful for integrating the resource to an external system, like an ERP, a marketing tool, a CRM, or whatever.", + "required": "optional", + "creatable": true, + "updatable": true, + "fetchable": true, + "filterable": true, + "sortable": true, + "example": "ANY-EXTERNAL-REFEFERNCE" + }, + "reference_origin": { + "type": "string", + "desc": "Any identifier of the third party system that defines the reference code.", + "required": "optional", + "creatable": true, + "updatable": true, + "fetchable": true, + "filterable": true, + "sortable": true, + "example": "ANY-EXTERNAL-REFEFERNCE-ORIGIN" + }, + "metadata": { + "type": "object", + "desc": "Set of key-value pairs that you can attach to the resource. This can be useful for storing additional information about the resource in a structured format.", + "required": "optional", + "creatable": true, + "updatable": true, + "fetchable": true, + "filterable": true, + "sortable": false, + "example": { + "foo": "bar" + } + }, + "_disable": { + "type": "boolean", + "trigger": true, + "desc": "Send this attribute if you want to mark this resource as disabled.", + "required": "optional", + "creatable": true, + "updatable": true, + "fetchable": false, + "filterable": false, + "sortable": false, + "example": "true", + "conditions": { + "include": "CoreMixins::Concerns::Disabled" + } + }, + "_enable": { + "type": "boolean", + "trigger": true, + "desc": "Send this attribute if you want to mark this resource as enabled.", + "required": "optional", + "creatable": true, + "updatable": true, + "fetchable": false, + "filterable": false, + "sortable": false, + "example": "true", + "conditions": { + "include": "CoreMixins::Concerns::Disabled" + } + }, + "disabled_at": { + "type": "datetime", + "desc": "Time at which this resource was disabled.", + "required": "optional", + "creatable": false, + "updatable": false, + "fetchable": true, + "filterable": true, + "sortable": true, + "example": "2018-01-01T12:00:00.000Z", + "conditions": { + "include": "CoreMixins::Concerns::Disabled" + } + } + }, + "relationships": { + "user": { + "type": "has_one", + "desc": "The user associated to the identity provider.", + "creatable": false, + "updatable": false, + "filterable": true, + "sortable": false, + "parent_resource": "V1::IdentityProviderResource", + "class_name": "User" + } + }, + "filters": [ + "id", + "name", + "client_id", + "client_secret", + "issuer", + "status", + "domains", + "token_url", + "authorize_url", + "jwks_url", + "txt_record", + "organization", + "created_at", + "updated_at", + "reference", + "reference_origin", + "metadata", + "disabled_at", + "q", + "user_id", + "ids", + "created_at_from", + "created_at_to", + "updated_at_from", + "updated_at_to", + "disabled_at_from", + "disabled_at_to" + ] + } + }, { "id": "membership", "type": "resources", @@ -1277,6 +1574,29 @@ "sortable": false, "example": "false" }, + "discount_engines_enabled": { + "type": "boolean", + "default": false, + "addon": true, + "desc": "Enables the use of an external discount engine in place of the standard one, default is {DISCOUNT_ENGINES_ENABLED}.", + "creatable": false, + "updatable": false, + "fetchable": true, + "filterable": false, + "sortable": false, + "example": "false" + }, + "discount_engines_errors": { + "type": "boolean", + "default": false, + "desc": "Enables raising of API errors in case of discount engine failure, default is {DISCOUNT_ENGINES_ERRORS}.", + "creatable": false, + "updatable": false, + "fetchable": true, + "filterable": false, + "sortable": false, + "example": "false" + }, "tax_calculators_errors": { "type": "boolean", "default": false, @@ -2027,7 +2347,7 @@ }, "status": { "type": "string", - "desc": "The subscription status. One of `draft` (default), `pending`, `activated`, `expired`, `canceled` or `on_error`.", + "desc": "The subscription status. One of `draft` (default), `pending`, `activated`, `expired`, `canceled` or `error`.", "creatable": false, "updatable": false, "fetchable": true, @@ -2040,7 +2360,7 @@ "activated", "expired", "canceled", - "on_error" + "error" ], "aasm": true }, @@ -2342,7 +2662,18 @@ } } }, - "relationships": {}, + "relationships": { + "identity_providers": { + "type": "has_many", + "desc": "The identity providers associated to the user.", + "creatable": false, + "updatable": false, + "filterable": true, + "sortable": false, + "parent_resource": "V1::UserResource", + "class_name": "IdentityProvider" + } + }, "filters": [ "id", "email", @@ -2355,6 +2686,7 @@ "reference_origin", "metadata", "q", + "identity_providers_id", "ids", "created_at_from", "created_at_to", diff --git a/gen/templates/singleton_update.tpl b/gen/templates/singleton_update.tpl index 9121efa..f2182ef 100644 --- a/gen/templates/singleton_update.tpl +++ b/gen/templates/singleton_update.tpl @@ -1,4 +1,3 @@ async update(resource: ##__RESOURCE_REQUEST_CLASS__##, params?: QueryParamsRetrieve<##__RESOURCE_RESPONSE_CLASS__##>, options?: ResourcesConfig): Promise<##__RESOURCE_RESPONSE_CLASS__##> { - const id = resource.id || (await this.retrieve()).id // JsonAPI requires id in the request body - return this.resources.update<##__RESOURCE_REQUEST_CLASS__##, ##__RESOURCE_RESPONSE_CLASS__##>({ ...resource, id, type: ##__RESOURCE_CLASS__##.TYPE }, params, options) + return this.resources.update<##__RESOURCE_REQUEST_CLASS__##, ##__RESOURCE_RESPONSE_CLASS__##>({ ...resource, type: ##__RESOURCE_CLASS__##.TYPE }, params, options) } \ No newline at end of file diff --git a/specs/resources/identity_providers.spec.ts b/specs/resources/identity_providers.spec.ts new file mode 100644 index 0000000..3bf1247 --- /dev/null +++ b/specs/resources/identity_providers.spec.ts @@ -0,0 +1,283 @@ +/** + * ©2024 Commerce Layer Inc. + * Source code generated automatically by SDK codegen + **/ + +import { CommerceLayerProvisioningClient, IdentityProvider } from '../../src' +import isEqual from 'lodash.isequal' +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { getClient, TestData, CommonData, handleError, interceptRequest, checkCommon, checkCommonData, checkCommonParamsList, checkCommonParams, currentAccessToken, randomValue } from '../../test/common' + + + +let clp: CommerceLayerProvisioningClient + + +beforeAll(async () => { clp = await getClient() }) + + +describe('IdentityProviders resource', () => { + + const resourceType = 'identity_providers' + const resourcePath = 'identity_providers' + + + /* spec.create.start */ + it(resourceType + '.create', async () => { + + const createAttributes = { + name: randomValue('string', 'name'), + client_id: randomValue('string', 'client_id'), + client_secret: randomValue('string', 'client_secret'), + issuer: randomValue('string', 'issuer'), + domains: randomValue('string', 'domains'), + token_url: randomValue('string', 'token_url'), + authorize_url: randomValue('string', 'authorize_url'), + jwks_url: randomValue('string', 'jwks_url'), + } + + const attributes = { ...createAttributes, reference: TestData.reference } + const params = { fields: { [resourceType]: CommonData.paramsFields } } + const resData = attributes + + const intId = clp.addRequestInterceptor((request) => { + const data = JSON.parse(String(request.options.body)) + expect(request.options.method).toBe('POST') + checkCommon(request, resourcePath) + checkCommonData(data, resourceType, attributes) + expect(clp[resourcePath].isIdentityProvider(data.data)).toBeTruthy() + return interceptRequest() + }) + + await clp[resourcePath].create(resData, params, CommonData.options) + .then((res: IdentityProvider) => expect(res).not.toBeNull()) + .catch(handleError) + .finally(() => clp.removeInterceptor('request', intId)) + + }) + /* spec.create.stop */ + + + /* spec.retrieve.start */ + it(resourceType + '.retrieve', async () => { + + const id = TestData.id + const params = { fields: {[resourceType]: CommonData.paramsFields } } + + const intId = clp.addRequestInterceptor((request) => { + expect(request.options.method).toBe('GET') + checkCommon(request, resourcePath, id, currentAccessToken) + checkCommonParams(request, params) + return interceptRequest() + }) + + await clp[resourcePath].retrieve(id, params, CommonData.options) + .then((res: IdentityProvider) => expect(res).not.toBeNull()) + .catch(handleError) + .finally(() => clp.removeInterceptor('request', intId)) + + }) + /* spec.retrieve.stop */ + + + /* spec.update.start */ + it(resourceType + '.update', async () => { + + const attributes = { reference_origin: TestData.reference_origin, metadata: TestData.metadata } + const params = { fields: { [resourceType]: CommonData.paramsFields } } + const resData = { id: TestData.id, ...attributes} + + const intId = clp.addRequestInterceptor((request) => { + if (request.options.method !== 'GET') { + const data = JSON.parse(String(request.options.body)) + expect(request.options.method).toBe('PATCH') + const id = clp.isSingleton(resourceType)? undefined : resData.id + checkCommon(request, resourcePath, id, currentAccessToken) + checkCommonData(data, resourceType, attributes, resData.id) + } + return interceptRequest() + }) + + await clp[resourcePath].update(resData, params, CommonData.options) + .then((res: IdentityProvider) => expect(res).not.toBeNull()) + .catch(handleError) + .finally(() => clp.removeInterceptor('request', intId)) + + }) + /* spec.update.stop */ + + + /* spec.delete.start */ + it(resourceType + '.delete', async () => { + + const id = TestData.id + + const intId = clp.addRequestInterceptor((request) => { + expect(request.options.method).toBe('DELETE') + checkCommon(request, resourcePath, id, currentAccessToken) + return interceptRequest() + }) + + await clp[resourcePath].delete(id, CommonData.options) + .catch(handleError) + .finally(() => clp.removeInterceptor('request', intId)) + + }) + /* spec.delete.stop */ + + + /* spec.list.start */ + it(resourceType + '.list', async () => { + + const params = CommonData.paramsList + + const intId = clp.addRequestInterceptor((request) => { + expect(request.options.method).toBe('GET') + checkCommon(request, resourcePath) + checkCommonParamsList(request, params) + return interceptRequest() + }) + + await clp[resourcePath].list(params, CommonData.options) + .catch(handleError) + .finally(() => clp.removeInterceptor('request', intId)) + + }) + /* spec.list.stop */ + + + /* spec.type.start */ + it(resourceType + '.type', async () => { + + const resource = { id: TestData.id, type: resourceType } + expect(clp[resourcePath].isIdentityProvider(resource)).toBeTruthy() + + const type = clp[resourcePath].type() + expect(type).toBe(resourceType) + + }) + /* spec.type.stop */ + + + /* spec.relationship.start */ + it(resourceType + '.relationship', async () => { + + const relId = clp[resourcePath].relationship(TestData.id) + expect(isEqual(relId, { id: TestData.id, type: resourceType})) + + const relResId = clp[resourcePath].relationship({ id: TestData.id, type: resourceType }) + expect(isEqual(relResId, { id: TestData.id, type: resourceType})) + + }) + /* spec.relationship.stop */ + + + /* spec.parse.start */ + it(resourceType + '.parse', async () => { + + const reference = 'myReferenceId' + + const payload = ` + { + "data": { + "id": "AbcdEfgHiL", + "meta": { + "mode": "test", + "organization_id": "myOrgId" + }, + "type": "${resourceType}", + "links": { + "self": "/api/${resourceType}/AbcdEfgHiL" + }, + "attributes": { + "metadata": {}, + "reference": "${reference}", + "created_at": "2023-10-01T05:53:29.296Z", + "updated_at": "2023-10-10T08:52:13.251Z" + } + } + } + ` + + const res = clp[resourcePath].parse(payload) as IdentityProvider + + expect(res.type).toBe(resourceType) + expect(res.reference).toBe(reference) + + }) + /* spec.parse.stop */ + + + + /* relationship.user start */ + it(resourceType + '.user', async () => { + + const id = TestData.id + const params = { fields: { user: CommonData.paramsFields } } + + const intId = clp.addRequestInterceptor((request) => { + expect(request.options.method).toBe('GET') + checkCommon(request, resourcePath, id, currentAccessToken, 'user') + checkCommonParams(request, params) + return interceptRequest() + }) + + await clp[resourcePath].user(id, params, CommonData.options) + .catch(handleError) + .finally(() => clp.removeInterceptor('request', intId)) + + }) + /* relationship.user stop */ + + + + /* trigger._disable start */ + it(resourceType + '._disable', async () => { + + let triggerAttr = '_disable' + if (!triggerAttr.startsWith('_')) triggerAttr = `_${triggerAttr}` + + const triggerValue = true + const attributes = { [triggerAttr]: triggerValue } + const id = TestData.id + + const intId = clp.addRequestInterceptor((request) => { + expect(request.options.method).toBe('PATCH') + checkCommon(request, resourcePath, id, currentAccessToken) + checkCommonData(request, resourceType, attributes, id) + return interceptRequest() + }) + + await clp[resourcePath]._disable(id, {}, CommonData.options) + .catch(handleError) + .finally(() => clp.removeInterceptor('request', intId)) + + }) + /* trigger._disable stop */ + + + /* trigger._enable start */ + it(resourceType + '._enable', async () => { + + let triggerAttr = '_enable' + if (!triggerAttr.startsWith('_')) triggerAttr = `_${triggerAttr}` + + const triggerValue = true + const attributes = { [triggerAttr]: triggerValue } + const id = TestData.id + + const intId = clp.addRequestInterceptor((request) => { + expect(request.options.method).toBe('PATCH') + checkCommon(request, resourcePath, id, currentAccessToken) + checkCommonData(request, resourceType, attributes, id) + return interceptRequest() + }) + + await clp[resourcePath]._enable(id, {}, CommonData.options) + .catch(handleError) + .finally(() => clp.removeInterceptor('request', intId)) + + }) + /* trigger._enable stop */ + +}) diff --git a/specs/resources/user.spec.ts b/specs/resources/user.spec.ts index eb89063..194b773 100644 --- a/specs/resources/user.spec.ts +++ b/specs/resources/user.spec.ts @@ -131,5 +131,26 @@ describe('Users resource', () => { /* spec.parse.stop */ + + /* relationship.identity_providers start */ + it(resourceType + '.identity_providers', async () => { + + const id = TestData.id + const params = { fields: { identity_providers: CommonData.paramsFields } } + + const intId = clp.addRequestInterceptor((request) => { + expect(request.options.method).toBe('GET') + checkCommon(request, resourcePath, id, currentAccessToken, 'identity_providers') + checkCommonParams(request, params) + return interceptRequest() + }) + + await clp[resourcePath].identity_providers(id, params, CommonData.options) + .catch(handleError) + .finally(() => clp.removeInterceptor('request', intId)) + + }) + /* relationship.identity_providers stop */ + }) diff --git a/src/api.ts b/src/api.ts index 9d64ffa..3f6ccde 100644 --- a/src/api.ts +++ b/src/api.ts @@ -9,6 +9,7 @@ import type * as models from './model' **/ export { default as ApiCredentials } from './resources/api_credentials' export { default as ApplicationMemberships } from './resources/application_memberships' +export { default as IdentityProviders } from './resources/identity_providers' export { default as Memberships } from './resources/memberships' export { default as Organizations } from './resources/organizations' export { default as Permissions } from './resources/permissions' @@ -22,6 +23,7 @@ export type ResourceTypeLock = // ##__API_RESOURCE_TYPES_START__## 'api_credentials' | 'application_memberships' +| 'identity_providers' | 'memberships' | 'organizations' | 'permissions' @@ -35,6 +37,7 @@ export const resourceList: ResourceTypeLock[] = [ // ##__API_RESOURCE_LIST_START__## 'api_credentials', 'application_memberships', + 'identity_providers', 'memberships', 'organizations', 'permissions', @@ -77,6 +80,7 @@ export type CreatableResourceType = // ##__API_RESOURCE_CREATABLE_START__## 'api_credentials' | 'application_memberships' +| 'identity_providers' | 'memberships' | 'organizations' | 'permissions' @@ -93,6 +97,7 @@ export type UpdatableResourceType = // ##__API_RESOURCE_UPDATABLE_START__## 'api_credentials' | 'application_memberships' +| 'identity_providers' | 'memberships' | 'organizations' | 'permissions' @@ -109,6 +114,7 @@ export type DeletableResourceType = // ##__API_RESOURCE_DELETABLE_START__## 'api_credentials' | 'application_memberships' +| 'identity_providers' | 'memberships' // ##__API_RESOURCE_DELETABLE_STOP__## @@ -136,6 +142,7 @@ export type ResourceFields = { // ##__API_RESOURCE_FIELDS_START__## api_credentials: models.ApiCredential, application_memberships: models.ApplicationMembership, + identity_providers: models.IdentityProvider, memberships: models.Membership, organizations: models.Organization, permissions: models.Permission, @@ -150,6 +157,7 @@ export type ResourceSortFields = { // ##__API_RESOURCE_SORTABLE_FIELDS_START__## api_credentials: models.ApiCredentialSort, application_memberships: models.ApplicationMembershipSort, + identity_providers: models.IdentityProviderSort, memberships: models.MembershipSort, organizations: models.OrganizationSort, permissions: models.PermissionSort, diff --git a/src/commercelayer.ts b/src/commercelayer.ts index 74ad861..cc4dfbd 100644 --- a/src/commercelayer.ts +++ b/src/commercelayer.ts @@ -11,7 +11,7 @@ const debug = Debug('commercelayer') // Autogenerated schema version number, do not remove this line -const OPEN_API_SCHEMA_VERSION = '1.0.5' +const OPEN_API_SCHEMA_VERSION = '1.0.6' export { OPEN_API_SCHEMA_VERSION } @@ -37,6 +37,7 @@ class CommerceLayerProvisioningClient { // ##__CL_RESOURCES_DEF_TEMPLATE:: ##__TAB__#####__RESOURCE_TYPE__##?: api.##__RESOURCE_CLASS__## #api_credentials?: api.ApiCredentials #application_memberships?: api.ApplicationMemberships + #identity_providers?: api.IdentityProviders #memberships?: api.Memberships #organizations?: api.Organizations #permissions?: api.Permissions @@ -63,6 +64,7 @@ class CommerceLayerProvisioningClient { // ##__CL_RESOURCES_LEAZY_LOADING_TEMPLATE:: ##__TAB__##get ##__RESOURCE_TYPE__##(): api.##__RESOURCE_CLASS__## { return this.###__RESOURCE_TYPE__## || (this.###__RESOURCE_TYPE__## = new api.##__RESOURCE_CLASS__##(this.#adapter)) } get api_credentials(): api.ApiCredentials { return this.#api_credentials || (this.#api_credentials = new api.ApiCredentials(this.#adapter)) } get application_memberships(): api.ApplicationMemberships { return this.#application_memberships || (this.#application_memberships = new api.ApplicationMemberships(this.#adapter)) } + get identity_providers(): api.IdentityProviders { return this.#identity_providers || (this.#identity_providers = new api.IdentityProviders(this.#adapter)) } get memberships(): api.Memberships { return this.#memberships || (this.#memberships = new api.Memberships(this.#adapter)) } get organizations(): api.Organizations { return this.#organizations || (this.#organizations = new api.Organizations(this.#adapter)) } get permissions(): api.Permissions { return this.#permissions || (this.#permissions = new api.Permissions(this.#adapter)) } diff --git a/src/model.ts b/src/model.ts index e909850..2741645 100644 --- a/src/model.ts +++ b/src/model.ts @@ -6,6 +6,7 @@ **/ export type { ApiCredential, ApiCredentialCreate, ApiCredentialUpdate, ApiCredentialSort } from './resources/api_credentials' export type { ApplicationMembership, ApplicationMembershipCreate, ApplicationMembershipUpdate, ApplicationMembershipSort } from './resources/application_memberships' +export type { IdentityProvider, IdentityProviderCreate, IdentityProviderUpdate, IdentityProviderSort } from './resources/identity_providers' export type { Membership, MembershipCreate, MembershipUpdate, MembershipSort } from './resources/memberships' export type { Organization, OrganizationCreate, OrganizationUpdate, OrganizationSort } from './resources/organizations' export type { Permission, PermissionCreate, PermissionUpdate, PermissionSort } from './resources/permissions' diff --git a/src/resources/identity_providers.ts b/src/resources/identity_providers.ts new file mode 100644 index 0000000..f89a202 --- /dev/null +++ b/src/resources/identity_providers.ts @@ -0,0 +1,262 @@ +import type { Nullable } from '../types' +import { ApiResource } from '../resource' +import type { Resource, ResourceCreate, ResourceUpdate, ResourceId, ResourcesConfig, ResourceRel, ResourceSort, /* ResourceFilter */ } from '../resource' +import type { QueryParamsRetrieve } from '../query' + +import type { User } from './users' + + +type IdentityProviderType = 'identity_providers' +type IdentityProviderRel = ResourceRel & { type: IdentityProviderType } + + +export type IdentityProviderSort = Pick & ResourceSort +// export type IdentityProviderFilter = Pick & ResourceFilter + + +interface IdentityProvider extends Resource { + + readonly type: IdentityProviderType + + /** + * The name of the Identity provider. + * @example ```"Org auth0"``` + */ + name: string + /** + * The client ID used for the auth workflow. + * @example ```"a6CDk5v1ZV99GrtOcfYVEZRnDDt"``` + */ + client_id: string + /** + * The client secret used for the auth workflow. + * @example ```"s6CD55v1ZV99ArtOcfYVEZRnDDf"``` + */ + client_secret: string + /** + * The issuer used for the auth workflow. + * @example ```"https://dev.auth987.com/"``` + */ + issuer: string + /** + * The identity provider status. One of `pending` (default), `verified` or `error`. + * @example ```"pending"``` + */ + status: 'pending' | 'verified' | 'error' + /** + * The list of domains in scope (comma-separated). + * @example ```"dev.auth987.com,stg.auth987.com"``` + */ + domains: string + /** + * The token URL used for the auth workflow. + * @example ```"https://dev.auth987.com/oauth/token"``` + */ + token_url: string + /** + * The authorize URL used for the auth workflow. + * @example ```"https://dev.auth987.com/authorize"``` + */ + authorize_url: string + /** + * The JWKS key store URL used for the auth workflow. + * @example ```"https://dev.auth987.com/.well-known/jwks.json"``` + */ + jwks_url: string + /** + * The TXT record value used to check the domain. + * @example ```"cl-verification=a6CDk5v"``` + */ + txt_record: string + /** + * The organization identifier for authorize params. + * @example ```"org_76gsfs5gd"``` + */ + organization?: Nullable + /** + * Time at which this resource was disabled. + * @example ```"2018-01-01T12:00:00.000Z"``` + */ + disabled_at: string + + user?: Nullable + +} + + +interface IdentityProviderCreate extends ResourceCreate { + + /** + * The name of the Identity provider. + * @example ```"Org auth0"``` + */ + name: string + /** + * The client ID used for the auth workflow. + * @example ```"a6CDk5v1ZV99GrtOcfYVEZRnDDt"``` + */ + client_id: string + /** + * The client secret used for the auth workflow. + * @example ```"s6CD55v1ZV99ArtOcfYVEZRnDDf"``` + */ + client_secret: string + /** + * The issuer used for the auth workflow. + * @example ```"https://dev.auth987.com/"``` + */ + issuer: string + /** + * The list of domains in scope (comma-separated). + * @example ```"dev.auth987.com,stg.auth987.com"``` + */ + domains: string + /** + * The token URL used for the auth workflow. + * @example ```"https://dev.auth987.com/oauth/token"``` + */ + token_url: string + /** + * The authorize URL used for the auth workflow. + * @example ```"https://dev.auth987.com/authorize"``` + */ + authorize_url: string + /** + * The JWKS key store URL used for the auth workflow. + * @example ```"https://dev.auth987.com/.well-known/jwks.json"``` + */ + jwks_url: string + /** + * The organization identifier for authorize params. + * @example ```"org_76gsfs5gd"``` + */ + organization?: Nullable + /** + * Send this attribute if you want to mark this resource as disabled. + * @example ```"true"``` + */ + _disable?: Nullable + /** + * Send this attribute if you want to mark this resource as enabled. + * @example ```"true"``` + */ + _enable?: Nullable + +} + + +interface IdentityProviderUpdate extends ResourceUpdate { + + /** + * The name of the Identity provider. + * @example ```"Org auth0"``` + */ + name?: Nullable + /** + * The client ID used for the auth workflow. + * @example ```"a6CDk5v1ZV99GrtOcfYVEZRnDDt"``` + */ + client_id?: Nullable + /** + * The client secret used for the auth workflow. + * @example ```"s6CD55v1ZV99ArtOcfYVEZRnDDf"``` + */ + client_secret?: Nullable + /** + * The issuer used for the auth workflow. + * @example ```"https://dev.auth987.com/"``` + */ + issuer?: Nullable + /** + * The list of domains in scope (comma-separated). + * @example ```"dev.auth987.com,stg.auth987.com"``` + */ + domains?: Nullable + /** + * The token URL used for the auth workflow. + * @example ```"https://dev.auth987.com/oauth/token"``` + */ + token_url?: Nullable + /** + * The authorize URL used for the auth workflow. + * @example ```"https://dev.auth987.com/authorize"``` + */ + authorize_url?: Nullable + /** + * The JWKS key store URL used for the auth workflow. + * @example ```"https://dev.auth987.com/.well-known/jwks.json"``` + */ + jwks_url?: Nullable + /** + * The organization identifier for authorize params. + * @example ```"org_76gsfs5gd"``` + */ + organization?: Nullable + /** + * Send this attribute if you want to mark this resource as disabled. + * @example ```"true"``` + */ + _disable?: Nullable + /** + * Send this attribute if you want to mark this resource as enabled. + * @example ```"true"``` + */ + _enable?: Nullable + +} + + +class IdentityProviders extends ApiResource { + + static readonly TYPE: IdentityProviderType = 'identity_providers' as const + + async create(resource: IdentityProviderCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.create({ ...resource, type: IdentityProviders.TYPE }, params, options) + } + + async update(resource: IdentityProviderUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.update({ ...resource, type: IdentityProviders.TYPE }, params, options) + } + + async delete(id: string | ResourceId, options?: ResourcesConfig): Promise { + await this.resources.delete((typeof id === 'string')? { id, type: IdentityProviders.TYPE } : id, options) + } + + async user(identityProviderId: string | IdentityProvider, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + const _identityProviderId = (identityProviderId as IdentityProvider).id || identityProviderId as string + return this.resources.fetch({ type: 'user' }, `identity_providers/${_identityProviderId}/user`, params, options) as unknown as User + } + + async _disable(id: string | IdentityProvider, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.update({ id: (typeof id === 'string')? id: id.id, type: IdentityProviders.TYPE, _disable: true }, params, options) + } + + async _enable(id: string | IdentityProvider, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.update({ id: (typeof id === 'string')? id: id.id, type: IdentityProviders.TYPE, _enable: true }, params, options) + } + + + isIdentityProvider(resource: any): resource is IdentityProvider { + return resource.type && (resource.type === IdentityProviders.TYPE) + } + + + relationship(id: string | ResourceId | null): IdentityProviderRel { + return super.relationshipOneToOne(id) + } + + relationshipToMany(...ids: string[]): IdentityProviderRel[] { + return super.relationshipOneToMany(...ids) + } + + + type(): IdentityProviderType { + return IdentityProviders.TYPE + } + +} + + +export default IdentityProviders + +export type { IdentityProvider, IdentityProviderCreate, IdentityProviderUpdate, IdentityProviderType } diff --git a/src/resources/organizations.ts b/src/resources/organizations.ts index c0e33b7..10df402 100644 --- a/src/resources/organizations.ts +++ b/src/resources/organizations.ts @@ -104,6 +104,15 @@ interface Organization extends Resource { * Enables the rules engine for flex promotions and price list rules. */ api_rules_engine: boolean + /** + * Forces the usage of the new Authentication API. + * @example ```"true"``` + */ + api_new_auth: boolean + /** + * Enables the purge of cached single resources when list is purged. + */ + api_purge_single_resource: boolean /** * Indicates if the phone attribute is required for addresses, default is true. * @example ```"true"``` @@ -172,6 +181,11 @@ interface Organization extends Resource { * @example ```"10"``` */ imports_max_concurrent_count: number + /** + * Enables purging of cached resources upon succeeded imports. + * @example ```"true"``` + */ + imports_purge_cache: boolean /** * The maximum number of active concurrent promotions allowed for your organization, default is 10. * @example ```"10"``` @@ -181,6 +195,14 @@ interface Organization extends Resource { * Enables triggering of webhooks during imports, default is false. */ imports_trigger_webhooks: number + /** + * Enables the use of an external discount engine in place of the standard one, default is false. + */ + discount_engines_enabled: boolean + /** + * Enables raising of API errors in case of discount engine failure, default is false. + */ + discount_engines_errors: boolean /** * Enables raising of API errors in case of tax calculation failure, default is false. */ diff --git a/src/resources/user.ts b/src/resources/user.ts index ea7607e..b845aff 100644 --- a/src/resources/user.ts +++ b/src/resources/user.ts @@ -1,8 +1,9 @@ import type { Nullable } from '../types' import { ApiSingleton } from '../resource' -import type { Resource, ResourceUpdate, ResourceId, ResourcesConfig, ResourceRel, ResourceSort, /* ResourceFilter */ } from '../resource' -import type { QueryParamsRetrieve } from '../query' +import type { Resource, ResourceUpdate, ResourceId, ResourcesConfig, ResourceRel, ListResponse, ResourceSort, /* ResourceFilter */ } from '../resource' +import type { QueryParamsRetrieve, QueryParamsList } from '../query' +import type { IdentityProvider } from './identity_providers' type UserType = 'user' @@ -41,7 +42,9 @@ interface User extends Resource { * The user 2FA setting. */ otp_required_for_login: boolean - + + identity_providers?: Nullable + } @@ -76,8 +79,12 @@ class Users extends ApiSingleton { static readonly TYPE: UserType = 'user' as const async update(resource: UserUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { - const id = resource.id || (await this.retrieve()).id // JsonAPI requires id in the request body - return this.resources.update({ ...resource, id, type: Users.TYPE }, params, options) + return this.resources.update({ ...resource, type: Users.TYPE }, params, options) + } + + async identity_providers(userId: string | User, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + const _userId = (userId as User).id || userId as string + return this.resources.fetch({ type: 'identity_providers' }, `user/${_userId}/identity_providers`, params, options) as unknown as ListResponse }