diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d297dbff..afdcca71 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,9 +26,9 @@ jobs: github.repository == 'stainless-sdks/knock-ruby' && (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Ruby - uses: ruby/setup-ruby@v1 + uses: ruby/setup-ruby@c4e5b1316158f92e3d49443a9d58b31d25ac0f8f # v1.306.0 with: bundler-cache: false - run: |- @@ -39,7 +39,7 @@ jobs: github.repository == 'stainless-sdks/knock-ruby' && !startsWith(github.ref, 'refs/heads/stl/') id: github-oidc - uses: actions/github-script@v8 + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 with: script: core.setOutput('github_token', await core.getIDToken()); @@ -60,9 +60,9 @@ jobs: if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Ruby - uses: ruby/setup-ruby@v1 + uses: ruby/setup-ruby@c4e5b1316158f92e3d49443a9d58b31d25ac0f8f # v1.306.0 with: bundler-cache: false - run: |- @@ -76,9 +76,9 @@ jobs: runs-on: ${{ github.repository == 'stainless-sdks/knock-ruby' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Ruby - uses: ruby/setup-ruby@v1 + uses: ruby/setup-ruby@c4e5b1316158f92e3d49443a9d58b31d25ac0f8f # v1.306.0 with: bundler-cache: false - run: |- diff --git a/.github/workflows/publish-gem.yml b/.github/workflows/publish-gem.yml index 9d3dfc8b..448d28d2 100644 --- a/.github/workflows/publish-gem.yml +++ b/.github/workflows/publish-gem.yml @@ -14,9 +14,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Ruby - uses: ruby/setup-ruby@v1 + uses: ruby/setup-ruby@c4e5b1316158f92e3d49443a9d58b31d25ac0f8f # v1.306.0 with: bundler-cache: false - run: |- diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index 3b8a1c88..28b9de73 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -12,7 +12,7 @@ jobs: if: github.repository == 'knocklabs/knock-ruby' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Check release environment run: | diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 44959ac4..f29e96b8 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.35.0" + ".": "1.36.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index ac5431c0..ceddeea3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 90 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/knock%2Fknock-c4b73cfc78e9b583cae6abe7c1f73caf2b81d9d8c4338819707f7089443b9754.yml -openapi_spec_hash: 8ee18f8419b62f10276dff5d35ee5f27 -config_hash: 32503026a45db991d0d102f25af40a77 +configured_endpoints: 94 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/knock/knock-8ce4e8d1b89387fd949bbe362b3500d56e309e00d5ff2b94668c1d9f4c20776d.yml +openapi_spec_hash: 23febe31df8bbfdc3114ba2ce9b021ed +config_hash: 625db64572b7ee0ee1dd00546e53fc5f diff --git a/CHANGELOG.md b/CHANGELOG.md index 962cfa00..4d63996b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,42 @@ # Changelog +## 1.36.0 (2026-05-31) + +Full Changelog: [v1.35.0...v1.36.0](https://github.com/knocklabs/knock-ruby/compare/v1.35.0...v1.36.0) + +### Features + +* **api:** added new unset preferences methods ([9b272e8](https://github.com/knocklabs/knock-ruby/commit/9b272e8ced5eb194a57d79ba442fba9539a0c0ef)) +* **api:** api update ([e697644](https://github.com/knocklabs/knock-ruby/commit/e697644fade546fea5be556f0f51024f8959228e)) +* **api:** api update ([cf13a4e](https://github.com/knocklabs/knock-ruby/commit/cf13a4eac94e30e2bd0256af75cb9547057890aa)) +* **api:** api update ([27e68a8](https://github.com/knocklabs/knock-ruby/commit/27e68a833d6045919ff9b61ee416cd65078c2aa3)) +* **api:** api update ([2d54bf7](https://github.com/knocklabs/knock-ruby/commit/2d54bf7fb14986bfcbe5a4f2cc4a797e65c8e670)) +* **api:** api update ([76bdadc](https://github.com/knocklabs/knock-ruby/commit/76bdadc2b8b10eecfbe70ed14a8f6c040e27374e)) +* **api:** api update ([373e78b](https://github.com/knocklabs/knock-ruby/commit/373e78b7f24449c77d98c0d05c897fdeb05641aa)) +* **api:** api update ([14c7bc7](https://github.com/knocklabs/knock-ruby/commit/14c7bc73e1677dc239ac48035ee0b034709750ae)) +* **api:** api update ([bd57879](https://github.com/knocklabs/knock-ruby/commit/bd578791c347de8b63caf60ba6340f19ac3a6a48)) +* **api:** api update ([da22d6e](https://github.com/knocklabs/knock-ruby/commit/da22d6e5573c3f093d081edcb6881ac23fcf9173)) +* **api:** api update ([628d4cc](https://github.com/knocklabs/knock-ruby/commit/628d4cc040ba05590a453be6824ea9329792f394)) +* **api:** api update ([f710ae2](https://github.com/knocklabs/knock-ruby/commit/f710ae264c9e1acdcf36b41b93e49cd7a8ebaf12)) +* **KNO-12791:** Add workflow recipient run APIs ([1e34f54](https://github.com/knocklabs/knock-ruby/commit/1e34f54ffff850939a1effd58cb9711b442d7a93)) +* support setting headers via env ([ad75b97](https://github.com/knocklabs/knock-ruby/commit/ad75b97225fd6634d7850dde00d5035e64d168a2)) + + +### Bug Fixes + +* align path encoding with RFC 3986 section 3.3 ([3e2268d](https://github.com/knocklabs/knock-ruby/commit/3e2268d3e0547fa66ad253e35c86da963cc36215)) +* **client:** elide content type header on requests without body ([4e8b8cf](https://github.com/knocklabs/knock-ruby/commit/4e8b8cfd2dbdd693a880d960df5e48baa29fce2b)) +* multipart encoding for file arrays ([0715076](https://github.com/knocklabs/knock-ruby/commit/0715076b3cb219501a9bedd7a449f4cedef2babb)) +* variable name typo ([cde1131](https://github.com/knocklabs/knock-ruby/commit/cde113151eb2879204409723971653616876fdee)) + + +### Chores + +* **internal:** more robust bootstrap script ([1023475](https://github.com/knocklabs/knock-ruby/commit/1023475aa6b6f5c04dae72aaf7ad397aa769e033)) +* **tests:** bump steady to v0.20.1 ([6eb6756](https://github.com/knocklabs/knock-ruby/commit/6eb6756ef89a7b99a3825bd5ab899bf2f0b030e2)) +* **tests:** bump steady to v0.20.2 ([4206b20](https://github.com/knocklabs/knock-ruby/commit/4206b20a8cd60362598da173185bbd236e659eff)) +* **tests:** bump steady to v0.22.1 ([5b37b24](https://github.com/knocklabs/knock-ruby/commit/5b37b2467d9d996161d02d5df3bbdf703f51bad7)) + ## 1.35.0 (2026-03-27) Full Changelog: [v1.34.0...v1.35.0](https://github.com/knocklabs/knock-ruby/compare/v1.34.0...v1.35.0) diff --git a/Gemfile.lock b/Gemfile.lock index 160fe40a..07907897 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,7 +11,7 @@ GIT PATH remote: . specs: - knockapi (1.35.0) + knockapi (1.36.0) cgi connection_pool diff --git a/README.md b/README.md index 8eed89b1..fcc79b32 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ To use this gem, install via Bundler by adding the following to your application ```ruby -gem "knockapi", "~> 1.35.0" +gem "knockapi", "~> 1.36.0" ``` diff --git a/lib/knockapi.rb b/lib/knockapi.rb index ea9e809e..937252f4 100644 --- a/lib/knockapi.rb +++ b/lib/knockapi.rb @@ -59,6 +59,7 @@ require_relative "knockapi/models/recipients/channel_data_request" require_relative "knockapi/models/recipients/preference_set_request" require_relative "knockapi/models/identify_user_request" +require_relative "knockapi/models/workflow_recipient_run" require_relative "knockapi/models/activity" require_relative "knockapi/models/audience_add_members_params" require_relative "knockapi/models/audience_list_members_params" @@ -132,6 +133,7 @@ require_relative "knockapi/models/object_set_params" require_relative "knockapi/models/object_set_preferences_params" require_relative "knockapi/models/object_unset_channel_data_params" +require_relative "knockapi/models/object_unset_preferences_params" require_relative "knockapi/models/page_info" require_relative "knockapi/models/providers/ms_team_check_auth_params" require_relative "knockapi/models/providers/ms_team_check_auth_response" @@ -214,8 +216,13 @@ require_relative "knockapi/models/user_set_channel_data_params" require_relative "knockapi/models/user_set_preferences_params" require_relative "knockapi/models/user_unset_channel_data_params" +require_relative "knockapi/models/user_unset_preferences_params" require_relative "knockapi/models/user_update_params" require_relative "knockapi/models/workflow_cancel_params" +require_relative "knockapi/models/workflow_recipient_run_detail" +require_relative "knockapi/models/workflow_recipient_run_event" +require_relative "knockapi/models/workflow_recipient_run_get_params" +require_relative "knockapi/models/workflow_recipient_run_list_params" require_relative "knockapi/models/workflow_trigger_params" require_relative "knockapi/models/workflow_trigger_response" require_relative "knockapi/models" @@ -245,4 +252,5 @@ require_relative "knockapi/resources/users/bulk" require_relative "knockapi/resources/users/feeds" require_relative "knockapi/resources/users/guides" +require_relative "knockapi/resources/workflow_recipient_runs" require_relative "knockapi/resources/workflows" diff --git a/lib/knockapi/client.rb b/lib/knockapi/client.rb index c5d7fb5d..1eaa5944 100644 --- a/lib/knockapi/client.rb +++ b/lib/knockapi/client.rb @@ -59,6 +59,11 @@ class Client < Knockapi::Internal::Transport::BaseClient # @return [Knockapi::Resources::Workflows] attr_reader :workflows + # A workflow run represents an individual execution of a workflow for a specific + # recipient. + # @return [Knockapi::Resources::WorkflowRecipientRuns] + attr_reader :workflow_recipient_runs + # A schedule is a per-recipient, timezone-aware configuration for when to invoke a # workflow. # @return [Knockapi::Resources::Schedules] @@ -117,6 +122,17 @@ def initialize( headers = { "x-knock-branch" => (@branch = branch&.to_s) } + custom_headers_env = ENV["KNOCK_CUSTOM_HEADERS"] + unless custom_headers_env.nil? + parsed = {} + custom_headers_env.split("\n").each do |line| + colon = line.index(":") + unless colon.nil? + parsed[line[0...colon].strip] = line[(colon + 1)..].strip + end + end + headers = parsed.merge(headers) + end @api_key = api_key.to_s @@ -139,6 +155,7 @@ def initialize( @providers = Knockapi::Resources::Providers.new(client: self) @integrations = Knockapi::Resources::Integrations.new(client: self) @workflows = Knockapi::Resources::Workflows.new(client: self) + @workflow_recipient_runs = Knockapi::Resources::WorkflowRecipientRuns.new(client: self) @schedules = Knockapi::Resources::Schedules.new(client: self) @channels = Knockapi::Resources::Channels.new(client: self) @audiences = Knockapi::Resources::Audiences.new(client: self) diff --git a/lib/knockapi/internal/transport/base_client.rb b/lib/knockapi/internal/transport/base_client.rb index 3c41400d..c7d3a9b4 100644 --- a/lib/knockapi/internal/transport/base_client.rb +++ b/lib/knockapi/internal/transport/base_client.rb @@ -306,6 +306,8 @@ def initialize( Knockapi::Internal::Util.deep_merge(*[req[:body], opts[:extra_body]].compact) end + headers.delete("content-type") if body.nil? + url = Knockapi::Internal::Util.join_parsed_uri( @base_url_components, {**req, path: path, query: query} diff --git a/lib/knockapi/internal/util.rb b/lib/knockapi/internal/util.rb index c4d54820..24ef15bf 100644 --- a/lib/knockapi/internal/util.rb +++ b/lib/knockapi/internal/util.rb @@ -157,7 +157,7 @@ def coerce_hash!(input) in Hash | nil => coerced coerced else - message = "Expected a #{Hash} or #{Knockapi::Internal::Type::BaseModel}, got #{data.inspect}" + message = "Expected a #{Hash} or #{Knockapi::Internal::Type::BaseModel}, got #{input.inspect}" raise ArgumentError.new(message) end end @@ -237,6 +237,11 @@ def dig(data, pick, &blk) end end + # @type [Regexp] + # + # https://www.rfc-editor.org/rfc/rfc3986.html#section-3.3 + RFC_3986_NOT_PCHARS = /[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/ + class << self # @api private # @@ -247,6 +252,15 @@ def uri_origin(uri) "#{uri.scheme}://#{uri.host}#{":#{uri.port}" unless uri.port == uri.default_port}" end + # @api private + # + # @param path [String, Integer] + # + # @return [String] + def encode_path(path) + path.to_s.gsub(Knockapi::Internal::Util::RFC_3986_NOT_PCHARS) { ERB::Util.url_encode(_1) } + end + # @api private # # @param path [String, Array] @@ -259,7 +273,7 @@ def interpolate_path(path) in [] "" in [String => p, *interpolations] - encoded = interpolations.map { ERB::Util.url_encode(_1) } + encoded = interpolations.map { encode_path(_1) } format(p, *encoded) end end @@ -576,10 +590,10 @@ def encode_query_params(query) case val in Knockapi::FilePart unless val.filename.nil? - filename = ERB::Util.url_encode(val.filename) + filename = encode_path(val.filename) y << "; filename=\"#{filename}\"" in Pathname | IO - filename = ERB::Util.url_encode(::File.basename(val.to_path)) + filename = encode_path(::File.basename(val.to_path)) y << "; filename=\"#{filename}\"" else end @@ -596,6 +610,7 @@ def encode_query_params(query) # # @return [Array(String, Enumerable)] private def encode_multipart_streaming(body) + # rubocop:disable Style/CaseEquality # RFC 1521 Section 7.2.1 says we should have 70 char maximum for boundary length boundary = SecureRandom.urlsafe_base64(46) @@ -605,7 +620,7 @@ def encode_query_params(query) in Hash body.each do |key, val| case val - in Array if val.all? { primitive?(_1) } + in Array if val.all? { primitive?(_1) || Knockapi::Internal::Type::FileInput === _1 } val.each do |v| write_multipart_chunk(y, boundary: boundary, key: key, val: v, closing: closing) end @@ -621,6 +636,7 @@ def encode_query_params(query) fused_io = fused_enum(strio) { closing.each(&:call) } [boundary, fused_io] + # rubocop:enable Style/CaseEquality end # @api private diff --git a/lib/knockapi/models.rb b/lib/knockapi/models.rb index 25a828f0..bada9db5 100644 --- a/lib/knockapi/models.rb +++ b/lib/knockapi/models.rb @@ -135,6 +135,8 @@ module Knockapi ObjectUnsetChannelDataParams = Knockapi::Models::ObjectUnsetChannelDataParams + ObjectUnsetPreferencesParams = Knockapi::Models::ObjectUnsetPreferencesParams + PageInfo = Knockapi::Models::PageInfo Providers = Knockapi::Models::Providers @@ -205,9 +207,21 @@ module Knockapi UserUnsetChannelDataParams = Knockapi::Models::UserUnsetChannelDataParams + UserUnsetPreferencesParams = Knockapi::Models::UserUnsetPreferencesParams + UserUpdateParams = Knockapi::Models::UserUpdateParams WorkflowCancelParams = Knockapi::Models::WorkflowCancelParams + WorkflowRecipientRun = Knockapi::Models::WorkflowRecipientRun + + WorkflowRecipientRunDetail = Knockapi::Models::WorkflowRecipientRunDetail + + WorkflowRecipientRunEvent = Knockapi::Models::WorkflowRecipientRunEvent + + WorkflowRecipientRunGetParams = Knockapi::Models::WorkflowRecipientRunGetParams + + WorkflowRecipientRunListParams = Knockapi::Models::WorkflowRecipientRunListParams + WorkflowTriggerParams = Knockapi::Models::WorkflowTriggerParams end diff --git a/lib/knockapi/models/condition.rb b/lib/knockapi/models/condition.rb index 9aad0aba..1639533a 100644 --- a/lib/knockapi/models/condition.rb +++ b/lib/knockapi/models/condition.rb @@ -49,6 +49,7 @@ module Operator EXISTS = :exists NOT_EXISTS = :not_exists CONTAINS_ALL = :contains_all + NOT_CONTAINS_ALL = :not_contains_all IS_TIMESTAMP = :is_timestamp IS_NOT_TIMESTAMP = :is_not_timestamp IS_TIMESTAMP_ON_OR_AFTER = :is_timestamp_on_or_after diff --git a/lib/knockapi/models/message_event.rb b/lib/knockapi/models/message_event.rb index 3f385976..8df97396 100644 --- a/lib/knockapi/models/message_event.rb +++ b/lib/knockapi/models/message_event.rb @@ -66,22 +66,22 @@ class MessageEvent < Knockapi::Internal::Type::BaseModel module Type extend Knockapi::Internal::Type::Enum + MESSAGE_READ = :"message.read" + MESSAGE_SENT = :"message.sent" + MESSAGE_SEEN = :"message.seen" MESSAGE_ARCHIVED = :"message.archived" - MESSAGE_BOUNCED = :"message.bounced" - MESSAGE_CREATED = :"message.created" + MESSAGE_QUEUED = :"message.queued" MESSAGE_DELIVERED = :"message.delivered" + MESSAGE_NOT_SENT = :"message.not_sent" + MESSAGE_BOUNCED = :"message.bounced" + MESSAGE_UNDELIVERED = :"message.undelivered" MESSAGE_DELIVERY_ATTEMPTED = :"message.delivery_attempted" - MESSAGE_INTERACTED = :"message.interacted" MESSAGE_LINK_CLICKED = :"message.link_clicked" - MESSAGE_NOT_SENT = :"message.not_sent" - MESSAGE_QUEUED = :"message.queued" - MESSAGE_READ = :"message.read" - MESSAGE_SEEN = :"message.seen" - MESSAGE_SENT = :"message.sent" + MESSAGE_INTERACTED = :"message.interacted" MESSAGE_UNARCHIVED = :"message.unarchived" - MESSAGE_UNDELIVERED = :"message.undelivered" - MESSAGE_UNREAD = :"message.unread" MESSAGE_UNSEEN = :"message.unseen" + MESSAGE_UNREAD = :"message.unread" + MESSAGE_CREATED = :"message.created" # @!method self.values # @return [Array] diff --git a/lib/knockapi/models/object_unset_preferences_params.rb b/lib/knockapi/models/object_unset_preferences_params.rb new file mode 100644 index 00000000..f07a330d --- /dev/null +++ b/lib/knockapi/models/object_unset_preferences_params.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +module Knockapi + module Models + # @see Knockapi::Resources::Objects#unset_preferences + class ObjectUnsetPreferencesParams < Knockapi::Internal::Type::BaseModel + extend Knockapi::Internal::Type::RequestParameters::Converter + include Knockapi::Internal::Type::RequestParameters + + # @!attribute collection + # + # @return [String] + required :collection, String + + # @!attribute object_id_ + # + # @return [String] + required :object_id_, String + + # @!attribute id + # + # @return [String] + required :id, String + + # @!method initialize(collection:, object_id_:, id:, request_options: {}) + # @param collection [String] + # @param object_id_ [String] + # @param id [String] + # @param request_options [Knockapi::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/knockapi/models/providers/ms_team_check_auth_response.rb b/lib/knockapi/models/providers/ms_team_check_auth_response.rb index 94961116..96833794 100644 --- a/lib/knockapi/models/providers/ms_team_check_auth_response.rb +++ b/lib/knockapi/models/providers/ms_team_check_auth_response.rb @@ -24,17 +24,25 @@ class Connection < Knockapi::Internal::Type::BaseModel # @return [Boolean] required :ok, Knockapi::Internal::Type::Boolean + # @!attribute ms_teams_tenant_id + # The Microsoft Teams tenant ID for the connected tenant. + # + # @return [String, nil] + optional :ms_teams_tenant_id, String, nil?: true + # @!attribute reason # The reason for the Microsoft Teams connection if it is not valid. # # @return [String, nil] optional :reason, String, nil?: true - # @!method initialize(ok:, reason: nil) + # @!method initialize(ok:, ms_teams_tenant_id: nil, reason: nil) # A Microsoft Teams connection object. # # @param ok [Boolean] Whether the Microsoft Teams connection is valid. # + # @param ms_teams_tenant_id [String, nil] The Microsoft Teams tenant ID for the connected tenant. + # # @param reason [String, nil] The reason for the Microsoft Teams connection if it is not valid. end end diff --git a/lib/knockapi/models/user_unset_preferences_params.rb b/lib/knockapi/models/user_unset_preferences_params.rb new file mode 100644 index 00000000..38ef7feb --- /dev/null +++ b/lib/knockapi/models/user_unset_preferences_params.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +module Knockapi + module Models + # @see Knockapi::Resources::Users#unset_preferences + class UserUnsetPreferencesParams < Knockapi::Internal::Type::BaseModel + extend Knockapi::Internal::Type::RequestParameters::Converter + include Knockapi::Internal::Type::RequestParameters + + # @!attribute user_id + # + # @return [String] + required :user_id, String + + # @!attribute id + # + # @return [String] + required :id, String + + # @!method initialize(user_id:, id:, request_options: {}) + # @param user_id [String] + # @param id [String] + # @param request_options [Knockapi::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/knockapi/models/users/guide_get_channel_response.rb b/lib/knockapi/models/users/guide_get_channel_response.rb index c3006989..96c7eddf 100644 --- a/lib/knockapi/models/users/guide_get_channel_response.rb +++ b/lib/knockapi/models/users/guide_get_channel_response.rb @@ -88,6 +88,12 @@ class Entry < Knockapi::Internal::Type::BaseModel # @return [String, nil] optional :channel_id, String + # @!attribute dashboard_url + # URL to this guide in the Knock dashboard + # + # @return [String, nil] + optional :dashboard_url, String + # @!attribute inserted_at # # @return [Time, nil] @@ -121,7 +127,7 @@ class Entry < Knockapi::Internal::Type::BaseModel # @return [Time, nil] optional :updated_at, Time - # @!method initialize(id: nil, _typename: nil, activation_url_patterns: nil, activation_url_rules: nil, active: nil, bypass_global_group_limit: nil, channel_id: nil, inserted_at: nil, key: nil, semver: nil, steps: nil, type: nil, updated_at: nil) + # @!method initialize(id: nil, _typename: nil, activation_url_patterns: nil, activation_url_rules: nil, active: nil, bypass_global_group_limit: nil, channel_id: nil, dashboard_url: nil, inserted_at: nil, key: nil, semver: nil, steps: nil, type: nil, updated_at: nil) # Some parameter documentations has been truncated, see # {Knockapi::Models::Users::GuideGetChannelResponse::Entry} for more details. # @@ -139,6 +145,8 @@ class Entry < Knockapi::Internal::Type::BaseModel # # @param channel_id [String] # + # @param dashboard_url [String] URL to this guide in the Knock dashboard + # # @param inserted_at [Time] # # @param key [String] The key of the guide. diff --git a/lib/knockapi/models/workflow_cancel_params.rb b/lib/knockapi/models/workflow_cancel_params.rb index e82ae474..6e0a45c9 100644 --- a/lib/knockapi/models/workflow_cancel_params.rb +++ b/lib/knockapi/models/workflow_cancel_params.rb @@ -13,11 +13,11 @@ class WorkflowCancelParams < Knockapi::Internal::Type::BaseModel required :key, String # @!attribute cancellation_key - # An optional key that is used to reference a specific workflow trigger request - # when issuing a [workflow cancellation](/send-notifications/canceling-workflows) - # request. Must be provided while triggering a workflow in order to enable - # subsequent cancellation. Should be unique across trigger requests to avoid - # unintentional cancellations. + # A key that is used to reference a specific workflow trigger request when issuing + # a [workflow cancellation](/send-notifications/canceling-workflows) request. Must + # be provided while triggering a workflow in order to enable subsequent + # cancellation. Should be unique across trigger requests to avoid unintentional + # cancellations. # # @return [String] required :cancellation_key, String @@ -37,7 +37,7 @@ class WorkflowCancelParams < Knockapi::Internal::Type::BaseModel # # @param key [String] # - # @param cancellation_key [String] An optional key that is used to reference a specific workflow trigger request wh + # @param cancellation_key [String] A key that is used to reference a specific workflow trigger request when issuing # # @param recipients [Array, nil] A list of recipients to cancel the notification for. If omitted, cancels for all # diff --git a/lib/knockapi/models/workflow_recipient_run.rb b/lib/knockapi/models/workflow_recipient_run.rb new file mode 100644 index 00000000..ea92ae82 --- /dev/null +++ b/lib/knockapi/models/workflow_recipient_run.rb @@ -0,0 +1,193 @@ +# frozen_string_literal: true + +module Knockapi + module Models + # @see Knockapi::Resources::WorkflowRecipientRuns#list + class WorkflowRecipientRun < Knockapi::Internal::Type::BaseModel + # @!attribute id + # The unique identifier for the workflow recipient run (per-recipient). + # + # @return [String] + required :id, String + + # @!attribute _typename + # The typename of the schema. + # + # @return [String] + required :_typename, String, api_name: :__typename + + # @!attribute inserted_at + # Timestamp when the resource was created. + # + # @return [Time] + required :inserted_at, Time + + # @!attribute recipient + # A reference to a recipient, either a user identifier (string) or an object + # reference (ID, collection). + # + # @return [String, Knockapi::Models::RecipientReference::ObjectReference] + required :recipient, union: -> { Knockapi::RecipientReference } + + # @!attribute status + # The current status of the workflow recipient run. One of `queued`, `processing`, + # `paused`, `completed`, or `cancelled`. + # + # @return [Symbol, Knockapi::Models::WorkflowRecipientRun::Status] + required :status, enum: -> { Knockapi::WorkflowRecipientRun::Status } + + # @!attribute trigger_source + # Describes how the workflow was triggered. + # + # @return [Knockapi::Models::WorkflowRecipientRun::TriggerSource] + required :trigger_source, -> { Knockapi::WorkflowRecipientRun::TriggerSource } + + # @!attribute updated_at + # The timestamp when the resource was last updated. + # + # @return [Time] + required :updated_at, Time + + # @!attribute workflow + # The key of the workflow that was executed. + # + # @return [String] + required :workflow, String + + # @!attribute workflow_run_id + # The identifier for the top-level workflow run shared across all recipients in a + # single trigger. + # + # @return [String] + required :workflow_run_id, String + + # @!attribute actor + # A reference to a recipient, either a user identifier (string) or an object + # reference (ID, collection). + # + # @return [String, Knockapi::Models::RecipientReference::ObjectReference, nil] + optional :actor, union: -> { Knockapi::RecipientReference }, nil?: true + + # @!attribute error_count + # The number of errors encountered during the workflow recipient run. + # + # @return [Integer, nil] + optional :error_count, Integer + + # @!attribute tenant + # The tenant associated with the workflow recipient run. + # + # @return [String, nil] + optional :tenant, String, nil?: true + + # @!method initialize(id:, _typename:, inserted_at:, recipient:, status:, trigger_source:, updated_at:, workflow:, workflow_run_id:, actor: nil, error_count: nil, tenant: nil) + # Some parameter documentations has been truncated, see + # {Knockapi::Models::WorkflowRecipientRun} for more details. + # + # A workflow recipient run represents an individual execution of a workflow for a + # specific recipient. + # + # @param id [String] The unique identifier for the workflow recipient run (per-recipient). + # + # @param _typename [String] The typename of the schema. + # + # @param inserted_at [Time] Timestamp when the resource was created. + # + # @param recipient [String, Knockapi::Models::RecipientReference::ObjectReference] A reference to a recipient, either a user identifier (string) or an object refer + # + # @param status [Symbol, Knockapi::Models::WorkflowRecipientRun::Status] The current status of the workflow recipient run. One of `queued`, `processing`, + # + # @param trigger_source [Knockapi::Models::WorkflowRecipientRun::TriggerSource] Describes how the workflow was triggered. + # + # @param updated_at [Time] The timestamp when the resource was last updated. + # + # @param workflow [String] The key of the workflow that was executed. + # + # @param workflow_run_id [String] The identifier for the top-level workflow run shared across all recipients in a + # + # @param actor [String, Knockapi::Models::RecipientReference::ObjectReference, nil] A reference to a recipient, either a user identifier (string) or an object refer + # + # @param error_count [Integer] The number of errors encountered during the workflow recipient run. + # + # @param tenant [String, nil] The tenant associated with the workflow recipient run. + + # The current status of the workflow recipient run. One of `queued`, `processing`, + # `paused`, `completed`, or `cancelled`. + # + # @see Knockapi::Models::WorkflowRecipientRun#status + module Status + extend Knockapi::Internal::Type::Enum + + QUEUED = :queued + PROCESSING = :processing + PAUSED = :paused + COMPLETED = :completed + CANCELLED = :cancelled + + # @!method self.values + # @return [Array] + end + + # @see Knockapi::Models::WorkflowRecipientRun#trigger_source + class TriggerSource < Knockapi::Internal::Type::BaseModel + # @!attribute type + # The type of trigger source. One of `api`, `audience`, `schedule`, `broadcast`, + # `workflow_step`, `integration`, or `rehearsal`. + # + # @return [Symbol, Knockapi::Models::WorkflowRecipientRun::TriggerSource::Type] + required :type, enum: -> { Knockapi::WorkflowRecipientRun::TriggerSource::Type } + + # @!attribute audience_key + # The key of the audience that triggered the workflow. + # + # @return [String, nil] + optional :audience_key, String, nil?: true + + # @!attribute cancellation_key + # The cancellation key provided when the workflow was triggered via the API. + # + # @return [String, nil] + optional :cancellation_key, String, nil?: true + + # @!attribute schedule_id + # The ID of the schedule that triggered the workflow. + # + # @return [String, nil] + optional :schedule_id, String, nil?: true + + # @!method initialize(type:, audience_key: nil, cancellation_key: nil, schedule_id: nil) + # Some parameter documentations has been truncated, see + # {Knockapi::Models::WorkflowRecipientRun::TriggerSource} for more details. + # + # Describes how the workflow was triggered. + # + # @param type [Symbol, Knockapi::Models::WorkflowRecipientRun::TriggerSource::Type] The type of trigger source. One of `api`, `audience`, `schedule`, `broadcast`, ` + # + # @param audience_key [String, nil] The key of the audience that triggered the workflow. + # + # @param cancellation_key [String, nil] The cancellation key provided when the workflow was triggered via the API. + # + # @param schedule_id [String, nil] The ID of the schedule that triggered the workflow. + + # The type of trigger source. One of `api`, `audience`, `schedule`, `broadcast`, + # `workflow_step`, `integration`, or `rehearsal`. + # + # @see Knockapi::Models::WorkflowRecipientRun::TriggerSource#type + module Type + extend Knockapi::Internal::Type::Enum + + API = :api + AUDIENCE = :audience + SCHEDULE = :schedule + BROADCAST = :broadcast + WORKFLOW_STEP = :workflow_step + INTEGRATION = :integration + REHEARSAL = :rehearsal + + # @!method self.values + # @return [Array] + end + end + end + end +end diff --git a/lib/knockapi/models/workflow_recipient_run_detail.rb b/lib/knockapi/models/workflow_recipient_run_detail.rb new file mode 100644 index 00000000..d124a59d --- /dev/null +++ b/lib/knockapi/models/workflow_recipient_run_detail.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Knockapi + module Models + # @see Knockapi::Resources::WorkflowRecipientRuns#get + class WorkflowRecipientRunDetail < Knockapi::Models::WorkflowRecipientRun + # @!attribute events + # A list of events that occurred during the workflow recipient run. + # + # @return [Array] + required :events, -> { Knockapi::Internal::Type::ArrayOf[Knockapi::WorkflowRecipientRunEvent] } + + # @!method initialize(events:) + # A single workflow recipient run with its events. + # + # @param events [Array] A list of events that occurred during the workflow recipient run. + end + end +end diff --git a/lib/knockapi/models/workflow_recipient_run_event.rb b/lib/knockapi/models/workflow_recipient_run_event.rb new file mode 100644 index 00000000..c1686318 --- /dev/null +++ b/lib/knockapi/models/workflow_recipient_run_event.rb @@ -0,0 +1,99 @@ +# frozen_string_literal: true + +module Knockapi + module Models + class WorkflowRecipientRunEvent < Knockapi::Internal::Type::BaseModel + # @!attribute id + # The unique identifier for the event. + # + # @return [String] + required :id, String + + # @!attribute _typename + # The typename of the schema. + # + # @return [String] + required :_typename, String, api_name: :__typename + + # @!attribute event + # The type of event that occurred. + # + # @return [String] + required :event, String + + # @!attribute inserted_at + # Timestamp when the resource was created. + # + # @return [Time] + required :inserted_at, Time + + # @!attribute status + # Whether the event represents a successful or error state. + # + # @return [Symbol, Knockapi::Models::WorkflowRecipientRunEvent::Status] + required :status, enum: -> { Knockapi::WorkflowRecipientRunEvent::Status } + + # @!attribute attempt + # The attempt number of the workflow recipient run event. Increments for each + # retry. + # + # @return [Integer, nil] + optional :attempt, Integer + + # @!attribute data + # Event-specific data associated with the event. + # + # @return [Hash{Symbol=>Object}, nil] + optional :data, Knockapi::Internal::Type::HashOf[Knockapi::Internal::Type::Unknown], nil?: true + + # @!attribute step_ref + # The reference of the workflow step associated with this event. + # + # @return [String, nil] + optional :step_ref, String, nil?: true + + # @!attribute step_type + # The type of workflow step associated with this event. + # + # @return [String, nil] + optional :step_type, String, nil?: true + + # @!method initialize(id:, _typename:, event:, inserted_at:, status:, attempt: nil, data: nil, step_ref: nil, step_type: nil) + # Some parameter documentations has been truncated, see + # {Knockapi::Models::WorkflowRecipientRunEvent} for more details. + # + # An event that occurred during a workflow recipient run. + # + # @param id [String] The unique identifier for the event. + # + # @param _typename [String] The typename of the schema. + # + # @param event [String] The type of event that occurred. + # + # @param inserted_at [Time] Timestamp when the resource was created. + # + # @param status [Symbol, Knockapi::Models::WorkflowRecipientRunEvent::Status] Whether the event represents a successful or error state. + # + # @param attempt [Integer] The attempt number of the workflow recipient run event. Increments for each retr + # + # @param data [Hash{Symbol=>Object}, nil] Event-specific data associated with the event. + # + # @param step_ref [String, nil] The reference of the workflow step associated with this event. + # + # @param step_type [String, nil] The type of workflow step associated with this event. + + # Whether the event represents a successful or error state. + # + # @see Knockapi::Models::WorkflowRecipientRunEvent#status + module Status + extend Knockapi::Internal::Type::Enum + + OK = :ok + ERROR = :error + + # @!method self.values + # @return [Array] + end + end + end +end diff --git a/lib/knockapi/models/workflow_recipient_run_get_params.rb b/lib/knockapi/models/workflow_recipient_run_get_params.rb new file mode 100644 index 00000000..f009524a --- /dev/null +++ b/lib/knockapi/models/workflow_recipient_run_get_params.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Knockapi + module Models + # @see Knockapi::Resources::WorkflowRecipientRuns#get + class WorkflowRecipientRunGetParams < Knockapi::Internal::Type::BaseModel + extend Knockapi::Internal::Type::RequestParameters::Converter + include Knockapi::Internal::Type::RequestParameters + + # @!attribute id + # + # @return [String] + required :id, String + + # @!method initialize(id:, request_options: {}) + # @param id [String] + # @param request_options [Knockapi::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/knockapi/models/workflow_recipient_run_list_params.rb b/lib/knockapi/models/workflow_recipient_run_list_params.rb new file mode 100644 index 00000000..e9ebedc0 --- /dev/null +++ b/lib/knockapi/models/workflow_recipient_run_list_params.rb @@ -0,0 +1,112 @@ +# frozen_string_literal: true + +module Knockapi + module Models + # @see Knockapi::Resources::WorkflowRecipientRuns#list + class WorkflowRecipientRunListParams < Knockapi::Internal::Type::BaseModel + extend Knockapi::Internal::Type::RequestParameters::Converter + include Knockapi::Internal::Type::RequestParameters + + # @!attribute after + # The cursor to fetch entries after. + # + # @return [String, nil] + optional :after, String + + # @!attribute before + # The cursor to fetch entries before. + # + # @return [String, nil] + optional :before, String + + # @!attribute ending_at + # Limits the results to workflow recipient runs started before the given date. + # + # @return [Time, nil] + optional :ending_at, Time + + # @!attribute has_errors + # Limits the results to workflow recipient runs that have errors. + # + # @return [Boolean, nil] + optional :has_errors, Knockapi::Internal::Type::Boolean + + # @!attribute page_size + # The number of items per page (defaults to 50). + # + # @return [Integer, nil] + optional :page_size, Integer + + # @!attribute recipient + # Limits the results to workflow recipient runs for the given recipient. Accepts a + # user ID string or an object reference with `id` and `collection`. + # + # @return [String, Knockapi::Models::RecipientReference::ObjectReference, nil] + optional :recipient, union: -> { Knockapi::RecipientReference } + + # @!attribute starting_at + # Limits the results to workflow recipient runs started after the given date. + # + # @return [Time, nil] + optional :starting_at, Time + + # @!attribute status + # Limits the results to workflow recipient runs with the given status. + # + # @return [Array, nil] + optional :status, + -> { Knockapi::Internal::Type::ArrayOf[enum: Knockapi::WorkflowRecipientRunListParams::Status] } + + # @!attribute tenant + # Limits the results to workflow recipient runs for the given tenant. + # + # @return [String, nil] + optional :tenant, String + + # @!attribute workflow + # Limits the results to workflow recipient runs for the given workflow key. + # + # @return [String, nil] + optional :workflow, String + + # @!method initialize(after: nil, before: nil, ending_at: nil, has_errors: nil, page_size: nil, recipient: nil, starting_at: nil, status: nil, tenant: nil, workflow: nil, request_options: {}) + # Some parameter documentations has been truncated, see + # {Knockapi::Models::WorkflowRecipientRunListParams} for more details. + # + # @param after [String] The cursor to fetch entries after. + # + # @param before [String] The cursor to fetch entries before. + # + # @param ending_at [Time] Limits the results to workflow recipient runs started before the given date. + # + # @param has_errors [Boolean] Limits the results to workflow recipient runs that have errors. + # + # @param page_size [Integer] The number of items per page (defaults to 50). + # + # @param recipient [String, Knockapi::Models::RecipientReference::ObjectReference] Limits the results to workflow recipient runs for the given recipient. Accepts a + # + # @param starting_at [Time] Limits the results to workflow recipient runs started after the given date. + # + # @param status [Array] Limits the results to workflow recipient runs with the given status. + # + # @param tenant [String] Limits the results to workflow recipient runs for the given tenant. + # + # @param workflow [String] Limits the results to workflow recipient runs for the given workflow key. + # + # @param request_options [Knockapi::RequestOptions, Hash{Symbol=>Object}] + + module Status + extend Knockapi::Internal::Type::Enum + + QUEUED = :queued + PROCESSING = :processing + PAUSED = :paused + COMPLETED = :completed + CANCELLED = :cancelled + + # @!method self.values + # @return [Array] + end + end + end +end diff --git a/lib/knockapi/models/workflow_trigger_params.rb b/lib/knockapi/models/workflow_trigger_params.rb index 3fcbd1c7..1ea61598 100644 --- a/lib/knockapi/models/workflow_trigger_params.rb +++ b/lib/knockapi/models/workflow_trigger_params.rb @@ -28,11 +28,11 @@ class WorkflowTriggerParams < Knockapi::Internal::Type::BaseModel optional :actor, union: -> { Knockapi::RecipientRequest }, nil?: true # @!attribute cancellation_key - # An optional key that is used to reference a specific workflow trigger request - # when issuing a [workflow cancellation](/send-notifications/canceling-workflows) - # request. Must be provided while triggering a workflow in order to enable - # subsequent cancellation. Should be unique across trigger requests to avoid - # unintentional cancellations. + # A key that is used to reference a specific workflow trigger request when issuing + # a [workflow cancellation](/send-notifications/canceling-workflows) request. Must + # be provided while triggering a workflow in order to enable subsequent + # cancellation. Should be unique across trigger requests to avoid unintentional + # cancellations. # # @return [String, nil] optional :cancellation_key, String, nil?: true @@ -62,7 +62,7 @@ class WorkflowTriggerParams < Knockapi::Internal::Type::BaseModel # # @param actor [String, Knockapi::Models::InlineIdentifyUserRequest, Knockapi::Models::InlineObjectRequest, nil] Specifies a recipient in a request. This can either be a user identifier (string # - # @param cancellation_key [String, nil] An optional key that is used to reference a specific workflow trigger request wh + # @param cancellation_key [String, nil] A key that is used to reference a specific workflow trigger request when issuing # # @param data [Hash{Symbol=>Object}, nil] An optional map of data to pass into the workflow execution. There is a 10MB lim # diff --git a/lib/knockapi/resources/objects.rb b/lib/knockapi/resources/objects.rb index 49786d9b..b114ba53 100644 --- a/lib/knockapi/resources/objects.rb +++ b/lib/knockapi/resources/objects.rb @@ -503,6 +503,30 @@ def unset_channel_data(collection, object_id_, channel_id, params = {}) ) end + # Unsets the preference set for the object, removing it entirely. + # + # @overload unset_preferences(collection, object_id_, id, request_options: {}) + # + # @param collection [String] The collection this object belongs to. + # + # @param object_id_ [String] Unique identifier for the object. + # + # @param id [String] Unique identifier for the preference set. + # + # @param request_options [Knockapi::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [nil] + # + # @see Knockapi::Models::ObjectUnsetPreferencesParams + def unset_preferences(collection, object_id_, id, params = {}) + @client.request( + method: :delete, + path: ["v1/objects/%1$s/%2$s/preferences/%3$s", collection, object_id_, id], + model: NilClass, + options: params[:request_options] + ) + end + # @api private # # @param client [Knockapi::Client] diff --git a/lib/knockapi/resources/users.rb b/lib/knockapi/resources/users.rb index b4df0367..18faf5cd 100644 --- a/lib/knockapi/resources/users.rb +++ b/lib/knockapi/resources/users.rb @@ -449,6 +449,28 @@ def unset_channel_data(user_id, channel_id, params = {}) ) end + # Unsets the preference set for the user, removing it entirely. + # + # @overload unset_preferences(user_id, id, request_options: {}) + # + # @param user_id [String] The unique identifier of the user. + # + # @param id [String] Unique identifier for the preference set. + # + # @param request_options [Knockapi::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [nil] + # + # @see Knockapi::Models::UserUnsetPreferencesParams + def unset_preferences(user_id, id, params = {}) + @client.request( + method: :delete, + path: ["v1/users/%1$s/preferences/%2$s", user_id, id], + model: NilClass, + options: params[:request_options] + ) + end + # @api private # # @param client [Knockapi::Client] diff --git a/lib/knockapi/resources/workflow_recipient_runs.rb b/lib/knockapi/resources/workflow_recipient_runs.rb new file mode 100644 index 00000000..6033692d --- /dev/null +++ b/lib/knockapi/resources/workflow_recipient_runs.rb @@ -0,0 +1,81 @@ +# frozen_string_literal: true + +module Knockapi + module Resources + # A workflow run represents an individual execution of a workflow for a specific + # recipient. + class WorkflowRecipientRuns + # Some parameter documentations has been truncated, see + # {Knockapi::Models::WorkflowRecipientRunListParams} for more details. + # + # Returns a paginated list of workflow recipient runs for the current environment. + # + # @overload list(after: nil, before: nil, ending_at: nil, has_errors: nil, page_size: nil, recipient: nil, starting_at: nil, status: nil, tenant: nil, workflow: nil, request_options: {}) + # + # @param after [String] The cursor to fetch entries after. + # + # @param before [String] The cursor to fetch entries before. + # + # @param ending_at [Time] Limits the results to workflow recipient runs started before the given date. + # + # @param has_errors [Boolean] Limits the results to workflow recipient runs that have errors. + # + # @param page_size [Integer] The number of items per page (defaults to 50). + # + # @param recipient [String, Knockapi::Models::RecipientReference::ObjectReference] Limits the results to workflow recipient runs for the given recipient. Accepts a + # + # @param starting_at [Time] Limits the results to workflow recipient runs started after the given date. + # + # @param status [Array] Limits the results to workflow recipient runs with the given status. + # + # @param tenant [String] Limits the results to workflow recipient runs for the given tenant. + # + # @param workflow [String] Limits the results to workflow recipient runs for the given workflow key. + # + # @param request_options [Knockapi::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Knockapi::Internal::ItemsCursor] + # + # @see Knockapi::Models::WorkflowRecipientRunListParams + def list(params = {}) + parsed, options = Knockapi::WorkflowRecipientRunListParams.dump_request(params) + query = Knockapi::Internal::Util.encode_query_params(parsed) + @client.request( + method: :get, + path: "v1/workflow_recipient_runs", + query: query, + page: Knockapi::Internal::ItemsCursor, + model: Knockapi::WorkflowRecipientRun, + options: options + ) + end + + # Returns a single workflow recipient run with its associated events. + # + # @overload get(id, request_options: {}) + # + # @param id [String] The unique identifier for the workflow recipient run (per-recipient). + # + # @param request_options [Knockapi::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Knockapi::Models::WorkflowRecipientRunDetail] + # + # @see Knockapi::Models::WorkflowRecipientRunGetParams + def get(id, params = {}) + @client.request( + method: :get, + path: ["v1/workflow_recipient_runs/%1$s", id], + model: Knockapi::WorkflowRecipientRunDetail, + options: params[:request_options] + ) + end + + # @api private + # + # @param client [Knockapi::Client] + def initialize(client:) + @client = client + end + end + end +end diff --git a/lib/knockapi/resources/workflows.rb b/lib/knockapi/resources/workflows.rb index d5825cd4..3dfbb80e 100644 --- a/lib/knockapi/resources/workflows.rb +++ b/lib/knockapi/resources/workflows.rb @@ -16,7 +16,7 @@ class Workflows # # @param key [String] The key of the workflow to cancel. # - # @param cancellation_key [String] An optional key that is used to reference a specific workflow trigger request wh + # @param cancellation_key [String] A key that is used to reference a specific workflow trigger request when issuing # # @param recipients [Array, nil] A list of recipients to cancel the notification for. If omitted, cancels for all # @@ -53,7 +53,7 @@ def cancel(key, params) # # @param actor [String, Knockapi::Models::InlineIdentifyUserRequest, Knockapi::Models::InlineObjectRequest, nil] Specifies a recipient in a request. This can either be a user identifier (string # - # @param cancellation_key [String, nil] An optional key that is used to reference a specific workflow trigger request wh + # @param cancellation_key [String, nil] A key that is used to reference a specific workflow trigger request when issuing # # @param data [Hash{Symbol=>Object}, nil] An optional map of data to pass into the workflow execution. There is a 10MB lim # diff --git a/lib/knockapi/version.rb b/lib/knockapi/version.rb index 97ce31a3..5a13de61 100644 --- a/lib/knockapi/version.rb +++ b/lib/knockapi/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Knockapi - VERSION = "1.35.0" + VERSION = "1.36.0" end diff --git a/rbi/knockapi/client.rbi b/rbi/knockapi/client.rbi index bc2f5dcf..40bd8d6b 100644 --- a/rbi/knockapi/client.rbi +++ b/rbi/knockapi/client.rbi @@ -54,6 +54,11 @@ module Knockapi sig { returns(Knockapi::Resources::Workflows) } attr_reader :workflows + # A workflow run represents an individual execution of a workflow for a specific + # recipient. + sig { returns(Knockapi::Resources::WorkflowRecipientRuns) } + attr_reader :workflow_recipient_runs + # A schedule is a per-recipient, timezone-aware configuration for when to invoke a # workflow. sig { returns(Knockapi::Resources::Schedules) } diff --git a/rbi/knockapi/internal/util.rbi b/rbi/knockapi/internal/util.rbi index 37d976cf..680cc9ab 100644 --- a/rbi/knockapi/internal/util.rbi +++ b/rbi/knockapi/internal/util.rbi @@ -148,12 +148,20 @@ module Knockapi end end + # https://www.rfc-editor.org/rfc/rfc3986.html#section-3.3 + RFC_3986_NOT_PCHARS = T.let(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/, Regexp) + class << self # @api private sig { params(uri: URI::Generic).returns(String) } def uri_origin(uri) end + # @api private + sig { params(path: T.any(String, Integer)).returns(String) } + def encode_path(path) + end + # @api private sig { params(path: T.any(String, T::Array[String])).returns(String) } def interpolate_path(path) diff --git a/rbi/knockapi/models.rbi b/rbi/knockapi/models.rbi index c9ede6d0..9333227f 100644 --- a/rbi/knockapi/models.rbi +++ b/rbi/knockapi/models.rbi @@ -101,6 +101,8 @@ module Knockapi ObjectUnsetChannelDataParams = Knockapi::Models::ObjectUnsetChannelDataParams + ObjectUnsetPreferencesParams = Knockapi::Models::ObjectUnsetPreferencesParams + PageInfo = Knockapi::Models::PageInfo Providers = Knockapi::Models::Providers @@ -171,9 +173,23 @@ module Knockapi UserUnsetChannelDataParams = Knockapi::Models::UserUnsetChannelDataParams + UserUnsetPreferencesParams = Knockapi::Models::UserUnsetPreferencesParams + UserUpdateParams = Knockapi::Models::UserUpdateParams WorkflowCancelParams = Knockapi::Models::WorkflowCancelParams + WorkflowRecipientRun = Knockapi::Models::WorkflowRecipientRun + + WorkflowRecipientRunDetail = Knockapi::Models::WorkflowRecipientRunDetail + + WorkflowRecipientRunEvent = Knockapi::Models::WorkflowRecipientRunEvent + + WorkflowRecipientRunGetParams = + Knockapi::Models::WorkflowRecipientRunGetParams + + WorkflowRecipientRunListParams = + Knockapi::Models::WorkflowRecipientRunListParams + WorkflowTriggerParams = Knockapi::Models::WorkflowTriggerParams end diff --git a/rbi/knockapi/models/condition.rbi b/rbi/knockapi/models/condition.rbi index f7f0d79f..c1f073fa 100644 --- a/rbi/knockapi/models/condition.rbi +++ b/rbi/knockapi/models/condition.rbi @@ -84,6 +84,8 @@ module Knockapi T.let(:not_exists, Knockapi::Condition::Operator::TaggedSymbol) CONTAINS_ALL = T.let(:contains_all, Knockapi::Condition::Operator::TaggedSymbol) + NOT_CONTAINS_ALL = + T.let(:not_contains_all, Knockapi::Condition::Operator::TaggedSymbol) IS_TIMESTAMP = T.let(:is_timestamp, Knockapi::Condition::Operator::TaggedSymbol) IS_NOT_TIMESTAMP = diff --git a/rbi/knockapi/models/message_event.rbi b/rbi/knockapi/models/message_event.rbi index 2795fb47..c0eb0d54 100644 --- a/rbi/knockapi/models/message_event.rbi +++ b/rbi/knockapi/models/message_event.rbi @@ -89,25 +89,33 @@ module Knockapi T.type_alias { T.all(Symbol, Knockapi::MessageEvent::Type) } OrSymbol = T.type_alias { T.any(Symbol, String) } + MESSAGE_READ = + T.let(:"message.read", Knockapi::MessageEvent::Type::TaggedSymbol) + MESSAGE_SENT = + T.let(:"message.sent", Knockapi::MessageEvent::Type::TaggedSymbol) + MESSAGE_SEEN = + T.let(:"message.seen", Knockapi::MessageEvent::Type::TaggedSymbol) MESSAGE_ARCHIVED = T.let(:"message.archived", Knockapi::MessageEvent::Type::TaggedSymbol) - MESSAGE_BOUNCED = - T.let(:"message.bounced", Knockapi::MessageEvent::Type::TaggedSymbol) - MESSAGE_CREATED = - T.let(:"message.created", Knockapi::MessageEvent::Type::TaggedSymbol) + MESSAGE_QUEUED = + T.let(:"message.queued", Knockapi::MessageEvent::Type::TaggedSymbol) MESSAGE_DELIVERED = T.let( :"message.delivered", Knockapi::MessageEvent::Type::TaggedSymbol ) - MESSAGE_DELIVERY_ATTEMPTED = + MESSAGE_NOT_SENT = + T.let(:"message.not_sent", Knockapi::MessageEvent::Type::TaggedSymbol) + MESSAGE_BOUNCED = + T.let(:"message.bounced", Knockapi::MessageEvent::Type::TaggedSymbol) + MESSAGE_UNDELIVERED = T.let( - :"message.delivery_attempted", + :"message.undelivered", Knockapi::MessageEvent::Type::TaggedSymbol ) - MESSAGE_INTERACTED = + MESSAGE_DELIVERY_ATTEMPTED = T.let( - :"message.interacted", + :"message.delivery_attempted", Knockapi::MessageEvent::Type::TaggedSymbol ) MESSAGE_LINK_CLICKED = @@ -115,30 +123,22 @@ module Knockapi :"message.link_clicked", Knockapi::MessageEvent::Type::TaggedSymbol ) - MESSAGE_NOT_SENT = - T.let(:"message.not_sent", Knockapi::MessageEvent::Type::TaggedSymbol) - MESSAGE_QUEUED = - T.let(:"message.queued", Knockapi::MessageEvent::Type::TaggedSymbol) - MESSAGE_READ = - T.let(:"message.read", Knockapi::MessageEvent::Type::TaggedSymbol) - MESSAGE_SEEN = - T.let(:"message.seen", Knockapi::MessageEvent::Type::TaggedSymbol) - MESSAGE_SENT = - T.let(:"message.sent", Knockapi::MessageEvent::Type::TaggedSymbol) - MESSAGE_UNARCHIVED = + MESSAGE_INTERACTED = T.let( - :"message.unarchived", + :"message.interacted", Knockapi::MessageEvent::Type::TaggedSymbol ) - MESSAGE_UNDELIVERED = + MESSAGE_UNARCHIVED = T.let( - :"message.undelivered", + :"message.unarchived", Knockapi::MessageEvent::Type::TaggedSymbol ) - MESSAGE_UNREAD = - T.let(:"message.unread", Knockapi::MessageEvent::Type::TaggedSymbol) MESSAGE_UNSEEN = T.let(:"message.unseen", Knockapi::MessageEvent::Type::TaggedSymbol) + MESSAGE_UNREAD = + T.let(:"message.unread", Knockapi::MessageEvent::Type::TaggedSymbol) + MESSAGE_CREATED = + T.let(:"message.created", Knockapi::MessageEvent::Type::TaggedSymbol) sig do override.returns(T::Array[Knockapi::MessageEvent::Type::TaggedSymbol]) diff --git a/rbi/knockapi/models/object_unset_preferences_params.rbi b/rbi/knockapi/models/object_unset_preferences_params.rbi new file mode 100644 index 00000000..9badfc64 --- /dev/null +++ b/rbi/knockapi/models/object_unset_preferences_params.rbi @@ -0,0 +1,51 @@ +# typed: strong + +module Knockapi + module Models + class ObjectUnsetPreferencesParams < Knockapi::Internal::Type::BaseModel + extend Knockapi::Internal::Type::RequestParameters::Converter + include Knockapi::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Knockapi::ObjectUnsetPreferencesParams, + Knockapi::Internal::AnyHash + ) + end + + sig { returns(String) } + attr_accessor :collection + + sig { returns(String) } + attr_accessor :object_id_ + + sig { returns(String) } + attr_accessor :id + + sig do + params( + collection: String, + object_id_: String, + id: String, + request_options: Knockapi::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new(collection:, object_id_:, id:, request_options: {}) + end + + sig do + override.returns( + { + collection: String, + object_id_: String, + id: String, + request_options: Knockapi::RequestOptions + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/knockapi/models/providers/ms_team_check_auth_response.rbi b/rbi/knockapi/models/providers/ms_team_check_auth_response.rbi index d4e5e99e..92f23907 100644 --- a/rbi/knockapi/models/providers/ms_team_check_auth_response.rbi +++ b/rbi/knockapi/models/providers/ms_team_check_auth_response.rbi @@ -65,26 +65,40 @@ module Knockapi sig { returns(T::Boolean) } attr_accessor :ok + # The Microsoft Teams tenant ID for the connected tenant. + sig { returns(T.nilable(String)) } + attr_accessor :ms_teams_tenant_id + # The reason for the Microsoft Teams connection if it is not valid. sig { returns(T.nilable(String)) } attr_accessor :reason # A Microsoft Teams connection object. sig do - params(ok: T::Boolean, reason: T.nilable(String)).returns( - T.attached_class - ) + params( + ok: T::Boolean, + ms_teams_tenant_id: T.nilable(String), + reason: T.nilable(String) + ).returns(T.attached_class) end def self.new( # Whether the Microsoft Teams connection is valid. ok:, + # The Microsoft Teams tenant ID for the connected tenant. + ms_teams_tenant_id: nil, # The reason for the Microsoft Teams connection if it is not valid. reason: nil ) end sig do - override.returns({ ok: T::Boolean, reason: T.nilable(String) }) + override.returns( + { + ok: T::Boolean, + ms_teams_tenant_id: T.nilable(String), + reason: T.nilable(String) + } + ) end def to_hash end diff --git a/rbi/knockapi/models/user_unset_preferences_params.rbi b/rbi/knockapi/models/user_unset_preferences_params.rbi new file mode 100644 index 00000000..a7cda0bb --- /dev/null +++ b/rbi/knockapi/models/user_unset_preferences_params.rbi @@ -0,0 +1,46 @@ +# typed: strong + +module Knockapi + module Models + class UserUnsetPreferencesParams < Knockapi::Internal::Type::BaseModel + extend Knockapi::Internal::Type::RequestParameters::Converter + include Knockapi::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Knockapi::UserUnsetPreferencesParams, + Knockapi::Internal::AnyHash + ) + end + + sig { returns(String) } + attr_accessor :user_id + + sig { returns(String) } + attr_accessor :id + + sig do + params( + user_id: String, + id: String, + request_options: Knockapi::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new(user_id:, id:, request_options: {}) + end + + sig do + override.returns( + { + user_id: String, + id: String, + request_options: Knockapi::RequestOptions + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/knockapi/models/users/guide_get_channel_response.rbi b/rbi/knockapi/models/users/guide_get_channel_response.rbi index 4c546889..d30d11d2 100644 --- a/rbi/knockapi/models/users/guide_get_channel_response.rbi +++ b/rbi/knockapi/models/users/guide_get_channel_response.rbi @@ -184,6 +184,13 @@ module Knockapi sig { params(channel_id: String).void } attr_writer :channel_id + # URL to this guide in the Knock dashboard + sig { returns(T.nilable(String)) } + attr_reader :dashboard_url + + sig { params(dashboard_url: String).void } + attr_writer :dashboard_url + sig { returns(T.nilable(Time)) } attr_reader :inserted_at @@ -252,6 +259,7 @@ module Knockapi active: T::Boolean, bypass_global_group_limit: T::Boolean, channel_id: String, + dashboard_url: String, inserted_at: Time, key: String, semver: String, @@ -278,6 +286,8 @@ module Knockapi active: nil, bypass_global_group_limit: nil, channel_id: nil, + # URL to this guide in the Knock dashboard + dashboard_url: nil, inserted_at: nil, # The key of the guide. key: nil, @@ -305,6 +315,7 @@ module Knockapi active: T::Boolean, bypass_global_group_limit: T::Boolean, channel_id: String, + dashboard_url: String, inserted_at: Time, key: String, semver: String, diff --git a/rbi/knockapi/models/workflow_cancel_params.rbi b/rbi/knockapi/models/workflow_cancel_params.rbi index 44c2053c..f71150ab 100644 --- a/rbi/knockapi/models/workflow_cancel_params.rbi +++ b/rbi/knockapi/models/workflow_cancel_params.rbi @@ -14,11 +14,11 @@ module Knockapi sig { returns(String) } attr_accessor :key - # An optional key that is used to reference a specific workflow trigger request - # when issuing a [workflow cancellation](/send-notifications/canceling-workflows) - # request. Must be provided while triggering a workflow in order to enable - # subsequent cancellation. Should be unique across trigger requests to avoid - # unintentional cancellations. + # A key that is used to reference a specific workflow trigger request when issuing + # a [workflow cancellation](/send-notifications/canceling-workflows) request. Must + # be provided while triggering a workflow in order to enable subsequent + # cancellation. Should be unique across trigger requests to avoid unintentional + # cancellations. sig { returns(String) } attr_accessor :cancellation_key @@ -53,11 +53,11 @@ module Knockapi end def self.new( key:, - # An optional key that is used to reference a specific workflow trigger request - # when issuing a [workflow cancellation](/send-notifications/canceling-workflows) - # request. Must be provided while triggering a workflow in order to enable - # subsequent cancellation. Should be unique across trigger requests to avoid - # unintentional cancellations. + # A key that is used to reference a specific workflow trigger request when issuing + # a [workflow cancellation](/send-notifications/canceling-workflows) request. Must + # be provided while triggering a workflow in order to enable subsequent + # cancellation. Should be unique across trigger requests to avoid unintentional + # cancellations. cancellation_key:, # A list of recipients to cancel the notification for. If omitted, cancels for all # recipients associated with the cancellation key. diff --git a/rbi/knockapi/models/workflow_recipient_run.rbi b/rbi/knockapi/models/workflow_recipient_run.rbi new file mode 100644 index 00000000..27e1586a --- /dev/null +++ b/rbi/knockapi/models/workflow_recipient_run.rbi @@ -0,0 +1,318 @@ +# typed: strong + +module Knockapi + module Models + class WorkflowRecipientRun < Knockapi::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Knockapi::WorkflowRecipientRun, Knockapi::Internal::AnyHash) + end + + # The unique identifier for the workflow recipient run (per-recipient). + sig { returns(String) } + attr_accessor :id + + # The typename of the schema. + sig { returns(String) } + attr_accessor :_typename + + # Timestamp when the resource was created. + sig { returns(Time) } + attr_accessor :inserted_at + + # A reference to a recipient, either a user identifier (string) or an object + # reference (ID, collection). + sig { returns(Knockapi::RecipientReference::Variants) } + attr_accessor :recipient + + # The current status of the workflow recipient run. One of `queued`, `processing`, + # `paused`, `completed`, or `cancelled`. + sig { returns(Knockapi::WorkflowRecipientRun::Status::TaggedSymbol) } + attr_accessor :status + + # Describes how the workflow was triggered. + sig { returns(Knockapi::WorkflowRecipientRun::TriggerSource) } + attr_reader :trigger_source + + sig do + params( + trigger_source: Knockapi::WorkflowRecipientRun::TriggerSource::OrHash + ).void + end + attr_writer :trigger_source + + # The timestamp when the resource was last updated. + sig { returns(Time) } + attr_accessor :updated_at + + # The key of the workflow that was executed. + sig { returns(String) } + attr_accessor :workflow + + # The identifier for the top-level workflow run shared across all recipients in a + # single trigger. + sig { returns(String) } + attr_accessor :workflow_run_id + + # A reference to a recipient, either a user identifier (string) or an object + # reference (ID, collection). + sig { returns(T.nilable(Knockapi::RecipientReference::Variants)) } + attr_accessor :actor + + # The number of errors encountered during the workflow recipient run. + sig { returns(T.nilable(Integer)) } + attr_reader :error_count + + sig { params(error_count: Integer).void } + attr_writer :error_count + + # The tenant associated with the workflow recipient run. + sig { returns(T.nilable(String)) } + attr_accessor :tenant + + # A workflow recipient run represents an individual execution of a workflow for a + # specific recipient. + sig do + params( + id: String, + _typename: String, + inserted_at: Time, + recipient: + T.any( + String, + Knockapi::RecipientReference::ObjectReference::OrHash + ), + status: Knockapi::WorkflowRecipientRun::Status::OrSymbol, + trigger_source: Knockapi::WorkflowRecipientRun::TriggerSource::OrHash, + updated_at: Time, + workflow: String, + workflow_run_id: String, + actor: + T.nilable( + T.any( + String, + Knockapi::RecipientReference::ObjectReference::OrHash + ) + ), + error_count: Integer, + tenant: T.nilable(String) + ).returns(T.attached_class) + end + def self.new( + # The unique identifier for the workflow recipient run (per-recipient). + id:, + # The typename of the schema. + _typename:, + # Timestamp when the resource was created. + inserted_at:, + # A reference to a recipient, either a user identifier (string) or an object + # reference (ID, collection). + recipient:, + # The current status of the workflow recipient run. One of `queued`, `processing`, + # `paused`, `completed`, or `cancelled`. + status:, + # Describes how the workflow was triggered. + trigger_source:, + # The timestamp when the resource was last updated. + updated_at:, + # The key of the workflow that was executed. + workflow:, + # The identifier for the top-level workflow run shared across all recipients in a + # single trigger. + workflow_run_id:, + # A reference to a recipient, either a user identifier (string) or an object + # reference (ID, collection). + actor: nil, + # The number of errors encountered during the workflow recipient run. + error_count: nil, + # The tenant associated with the workflow recipient run. + tenant: nil + ) + end + + sig do + override.returns( + { + id: String, + _typename: String, + inserted_at: Time, + recipient: Knockapi::RecipientReference::Variants, + status: Knockapi::WorkflowRecipientRun::Status::TaggedSymbol, + trigger_source: Knockapi::WorkflowRecipientRun::TriggerSource, + updated_at: Time, + workflow: String, + workflow_run_id: String, + actor: T.nilable(Knockapi::RecipientReference::Variants), + error_count: Integer, + tenant: T.nilable(String) + } + ) + end + def to_hash + end + + # The current status of the workflow recipient run. One of `queued`, `processing`, + # `paused`, `completed`, or `cancelled`. + module Status + extend Knockapi::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Knockapi::WorkflowRecipientRun::Status) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + QUEUED = + T.let(:queued, Knockapi::WorkflowRecipientRun::Status::TaggedSymbol) + PROCESSING = + T.let( + :processing, + Knockapi::WorkflowRecipientRun::Status::TaggedSymbol + ) + PAUSED = + T.let(:paused, Knockapi::WorkflowRecipientRun::Status::TaggedSymbol) + COMPLETED = + T.let( + :completed, + Knockapi::WorkflowRecipientRun::Status::TaggedSymbol + ) + CANCELLED = + T.let( + :cancelled, + Knockapi::WorkflowRecipientRun::Status::TaggedSymbol + ) + + sig do + override.returns( + T::Array[Knockapi::WorkflowRecipientRun::Status::TaggedSymbol] + ) + end + def self.values + end + end + + class TriggerSource < Knockapi::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Knockapi::WorkflowRecipientRun::TriggerSource, + Knockapi::Internal::AnyHash + ) + end + + # The type of trigger source. One of `api`, `audience`, `schedule`, `broadcast`, + # `workflow_step`, `integration`, or `rehearsal`. + sig do + returns( + Knockapi::WorkflowRecipientRun::TriggerSource::Type::TaggedSymbol + ) + end + attr_accessor :type + + # The key of the audience that triggered the workflow. + sig { returns(T.nilable(String)) } + attr_accessor :audience_key + + # The cancellation key provided when the workflow was triggered via the API. + sig { returns(T.nilable(String)) } + attr_accessor :cancellation_key + + # The ID of the schedule that triggered the workflow. + sig { returns(T.nilable(String)) } + attr_accessor :schedule_id + + # Describes how the workflow was triggered. + sig do + params( + type: Knockapi::WorkflowRecipientRun::TriggerSource::Type::OrSymbol, + audience_key: T.nilable(String), + cancellation_key: T.nilable(String), + schedule_id: T.nilable(String) + ).returns(T.attached_class) + end + def self.new( + # The type of trigger source. One of `api`, `audience`, `schedule`, `broadcast`, + # `workflow_step`, `integration`, or `rehearsal`. + type:, + # The key of the audience that triggered the workflow. + audience_key: nil, + # The cancellation key provided when the workflow was triggered via the API. + cancellation_key: nil, + # The ID of the schedule that triggered the workflow. + schedule_id: nil + ) + end + + sig do + override.returns( + { + type: + Knockapi::WorkflowRecipientRun::TriggerSource::Type::TaggedSymbol, + audience_key: T.nilable(String), + cancellation_key: T.nilable(String), + schedule_id: T.nilable(String) + } + ) + end + def to_hash + end + + # The type of trigger source. One of `api`, `audience`, `schedule`, `broadcast`, + # `workflow_step`, `integration`, or `rehearsal`. + module Type + extend Knockapi::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all(Symbol, Knockapi::WorkflowRecipientRun::TriggerSource::Type) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + API = + T.let( + :api, + Knockapi::WorkflowRecipientRun::TriggerSource::Type::TaggedSymbol + ) + AUDIENCE = + T.let( + :audience, + Knockapi::WorkflowRecipientRun::TriggerSource::Type::TaggedSymbol + ) + SCHEDULE = + T.let( + :schedule, + Knockapi::WorkflowRecipientRun::TriggerSource::Type::TaggedSymbol + ) + BROADCAST = + T.let( + :broadcast, + Knockapi::WorkflowRecipientRun::TriggerSource::Type::TaggedSymbol + ) + WORKFLOW_STEP = + T.let( + :workflow_step, + Knockapi::WorkflowRecipientRun::TriggerSource::Type::TaggedSymbol + ) + INTEGRATION = + T.let( + :integration, + Knockapi::WorkflowRecipientRun::TriggerSource::Type::TaggedSymbol + ) + REHEARSAL = + T.let( + :rehearsal, + Knockapi::WorkflowRecipientRun::TriggerSource::Type::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Knockapi::WorkflowRecipientRun::TriggerSource::Type::TaggedSymbol + ] + ) + end + def self.values + end + end + end + end + end +end diff --git a/rbi/knockapi/models/workflow_recipient_run_detail.rbi b/rbi/knockapi/models/workflow_recipient_run_detail.rbi new file mode 100644 index 00000000..ecb2a79d --- /dev/null +++ b/rbi/knockapi/models/workflow_recipient_run_detail.rbi @@ -0,0 +1,39 @@ +# typed: strong + +module Knockapi + module Models + class WorkflowRecipientRunDetail < Knockapi::Models::WorkflowRecipientRun + OrHash = + T.type_alias do + T.any( + Knockapi::WorkflowRecipientRunDetail, + Knockapi::Internal::AnyHash + ) + end + + # A list of events that occurred during the workflow recipient run. + sig { returns(T::Array[Knockapi::WorkflowRecipientRunEvent]) } + attr_accessor :events + + # A single workflow recipient run with its events. + sig do + params( + events: T::Array[Knockapi::WorkflowRecipientRunEvent::OrHash] + ).returns(T.attached_class) + end + def self.new( + # A list of events that occurred during the workflow recipient run. + events: + ) + end + + sig do + override.returns( + { events: T::Array[Knockapi::WorkflowRecipientRunEvent] } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/knockapi/models/workflow_recipient_run_event.rbi b/rbi/knockapi/models/workflow_recipient_run_event.rbi new file mode 100644 index 00000000..2ebf781c --- /dev/null +++ b/rbi/knockapi/models/workflow_recipient_run_event.rbi @@ -0,0 +1,137 @@ +# typed: strong + +module Knockapi + module Models + class WorkflowRecipientRunEvent < Knockapi::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Knockapi::WorkflowRecipientRunEvent, + Knockapi::Internal::AnyHash + ) + end + + # The unique identifier for the event. + sig { returns(String) } + attr_accessor :id + + # The typename of the schema. + sig { returns(String) } + attr_accessor :_typename + + # The type of event that occurred. + sig { returns(String) } + attr_accessor :event + + # Timestamp when the resource was created. + sig { returns(Time) } + attr_accessor :inserted_at + + # Whether the event represents a successful or error state. + sig { returns(Knockapi::WorkflowRecipientRunEvent::Status::TaggedSymbol) } + attr_accessor :status + + # The attempt number of the workflow recipient run event. Increments for each + # retry. + sig { returns(T.nilable(Integer)) } + attr_reader :attempt + + sig { params(attempt: Integer).void } + attr_writer :attempt + + # Event-specific data associated with the event. + sig { returns(T.nilable(T::Hash[Symbol, T.anything])) } + attr_accessor :data + + # The reference of the workflow step associated with this event. + sig { returns(T.nilable(String)) } + attr_accessor :step_ref + + # The type of workflow step associated with this event. + sig { returns(T.nilable(String)) } + attr_accessor :step_type + + # An event that occurred during a workflow recipient run. + sig do + params( + id: String, + _typename: String, + event: String, + inserted_at: Time, + status: Knockapi::WorkflowRecipientRunEvent::Status::OrSymbol, + attempt: Integer, + data: T.nilable(T::Hash[Symbol, T.anything]), + step_ref: T.nilable(String), + step_type: T.nilable(String) + ).returns(T.attached_class) + end + def self.new( + # The unique identifier for the event. + id:, + # The typename of the schema. + _typename:, + # The type of event that occurred. + event:, + # Timestamp when the resource was created. + inserted_at:, + # Whether the event represents a successful or error state. + status:, + # The attempt number of the workflow recipient run event. Increments for each + # retry. + attempt: nil, + # Event-specific data associated with the event. + data: nil, + # The reference of the workflow step associated with this event. + step_ref: nil, + # The type of workflow step associated with this event. + step_type: nil + ) + end + + sig do + override.returns( + { + id: String, + _typename: String, + event: String, + inserted_at: Time, + status: Knockapi::WorkflowRecipientRunEvent::Status::TaggedSymbol, + attempt: Integer, + data: T.nilable(T::Hash[Symbol, T.anything]), + step_ref: T.nilable(String), + step_type: T.nilable(String) + } + ) + end + def to_hash + end + + # Whether the event represents a successful or error state. + module Status + extend Knockapi::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all(Symbol, Knockapi::WorkflowRecipientRunEvent::Status) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + OK = + T.let(:ok, Knockapi::WorkflowRecipientRunEvent::Status::TaggedSymbol) + ERROR = + T.let( + :error, + Knockapi::WorkflowRecipientRunEvent::Status::TaggedSymbol + ) + + sig do + override.returns( + T::Array[Knockapi::WorkflowRecipientRunEvent::Status::TaggedSymbol] + ) + end + def self.values + end + end + end + end +end diff --git a/rbi/knockapi/models/workflow_recipient_run_get_params.rbi b/rbi/knockapi/models/workflow_recipient_run_get_params.rbi new file mode 100644 index 00000000..20cc9785 --- /dev/null +++ b/rbi/knockapi/models/workflow_recipient_run_get_params.rbi @@ -0,0 +1,38 @@ +# typed: strong + +module Knockapi + module Models + class WorkflowRecipientRunGetParams < Knockapi::Internal::Type::BaseModel + extend Knockapi::Internal::Type::RequestParameters::Converter + include Knockapi::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Knockapi::WorkflowRecipientRunGetParams, + Knockapi::Internal::AnyHash + ) + end + + sig { returns(String) } + attr_accessor :id + + sig do + params( + id: String, + request_options: Knockapi::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new(id:, request_options: {}) + end + + sig do + override.returns( + { id: String, request_options: Knockapi::RequestOptions } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/knockapi/models/workflow_recipient_run_list_params.rbi b/rbi/knockapi/models/workflow_recipient_run_list_params.rbi new file mode 100644 index 00000000..f4520da4 --- /dev/null +++ b/rbi/knockapi/models/workflow_recipient_run_list_params.rbi @@ -0,0 +1,229 @@ +# typed: strong + +module Knockapi + module Models + class WorkflowRecipientRunListParams < Knockapi::Internal::Type::BaseModel + extend Knockapi::Internal::Type::RequestParameters::Converter + include Knockapi::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Knockapi::WorkflowRecipientRunListParams, + Knockapi::Internal::AnyHash + ) + end + + # The cursor to fetch entries after. + sig { returns(T.nilable(String)) } + attr_reader :after + + sig { params(after: String).void } + attr_writer :after + + # The cursor to fetch entries before. + sig { returns(T.nilable(String)) } + attr_reader :before + + sig { params(before: String).void } + attr_writer :before + + # Limits the results to workflow recipient runs started before the given date. + sig { returns(T.nilable(Time)) } + attr_reader :ending_at + + sig { params(ending_at: Time).void } + attr_writer :ending_at + + # Limits the results to workflow recipient runs that have errors. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :has_errors + + sig { params(has_errors: T::Boolean).void } + attr_writer :has_errors + + # The number of items per page (defaults to 50). + sig { returns(T.nilable(Integer)) } + attr_reader :page_size + + sig { params(page_size: Integer).void } + attr_writer :page_size + + # Limits the results to workflow recipient runs for the given recipient. Accepts a + # user ID string or an object reference with `id` and `collection`. + sig do + returns( + T.nilable( + T.any(String, Knockapi::RecipientReference::ObjectReference) + ) + ) + end + attr_reader :recipient + + sig do + params( + recipient: + T.any(String, Knockapi::RecipientReference::ObjectReference::OrHash) + ).void + end + attr_writer :recipient + + # Limits the results to workflow recipient runs started after the given date. + sig { returns(T.nilable(Time)) } + attr_reader :starting_at + + sig { params(starting_at: Time).void } + attr_writer :starting_at + + # Limits the results to workflow recipient runs with the given status. + sig do + returns( + T.nilable( + T::Array[Knockapi::WorkflowRecipientRunListParams::Status::OrSymbol] + ) + ) + end + attr_reader :status + + sig do + params( + status: + T::Array[Knockapi::WorkflowRecipientRunListParams::Status::OrSymbol] + ).void + end + attr_writer :status + + # Limits the results to workflow recipient runs for the given tenant. + sig { returns(T.nilable(String)) } + attr_reader :tenant + + sig { params(tenant: String).void } + attr_writer :tenant + + # Limits the results to workflow recipient runs for the given workflow key. + sig { returns(T.nilable(String)) } + attr_reader :workflow + + sig { params(workflow: String).void } + attr_writer :workflow + + sig do + params( + after: String, + before: String, + ending_at: Time, + has_errors: T::Boolean, + page_size: Integer, + recipient: + T.any( + String, + Knockapi::RecipientReference::ObjectReference::OrHash + ), + starting_at: Time, + status: + T::Array[ + Knockapi::WorkflowRecipientRunListParams::Status::OrSymbol + ], + tenant: String, + workflow: String, + request_options: Knockapi::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # The cursor to fetch entries after. + after: nil, + # The cursor to fetch entries before. + before: nil, + # Limits the results to workflow recipient runs started before the given date. + ending_at: nil, + # Limits the results to workflow recipient runs that have errors. + has_errors: nil, + # The number of items per page (defaults to 50). + page_size: nil, + # Limits the results to workflow recipient runs for the given recipient. Accepts a + # user ID string or an object reference with `id` and `collection`. + recipient: nil, + # Limits the results to workflow recipient runs started after the given date. + starting_at: nil, + # Limits the results to workflow recipient runs with the given status. + status: nil, + # Limits the results to workflow recipient runs for the given tenant. + tenant: nil, + # Limits the results to workflow recipient runs for the given workflow key. + workflow: nil, + request_options: {} + ) + end + + sig do + override.returns( + { + after: String, + before: String, + ending_at: Time, + has_errors: T::Boolean, + page_size: Integer, + recipient: + T.any(String, Knockapi::RecipientReference::ObjectReference), + starting_at: Time, + status: + T::Array[ + Knockapi::WorkflowRecipientRunListParams::Status::OrSymbol + ], + tenant: String, + workflow: String, + request_options: Knockapi::RequestOptions + } + ) + end + def to_hash + end + + module Status + extend Knockapi::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all(Symbol, Knockapi::WorkflowRecipientRunListParams::Status) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + QUEUED = + T.let( + :queued, + Knockapi::WorkflowRecipientRunListParams::Status::TaggedSymbol + ) + PROCESSING = + T.let( + :processing, + Knockapi::WorkflowRecipientRunListParams::Status::TaggedSymbol + ) + PAUSED = + T.let( + :paused, + Knockapi::WorkflowRecipientRunListParams::Status::TaggedSymbol + ) + COMPLETED = + T.let( + :completed, + Knockapi::WorkflowRecipientRunListParams::Status::TaggedSymbol + ) + CANCELLED = + T.let( + :cancelled, + Knockapi::WorkflowRecipientRunListParams::Status::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Knockapi::WorkflowRecipientRunListParams::Status::TaggedSymbol + ] + ) + end + def self.values + end + end + end + end +end diff --git a/rbi/knockapi/models/workflow_trigger_params.rbi b/rbi/knockapi/models/workflow_trigger_params.rbi index cac4fc87..87ce315e 100644 --- a/rbi/knockapi/models/workflow_trigger_params.rbi +++ b/rbi/knockapi/models/workflow_trigger_params.rbi @@ -45,11 +45,11 @@ module Knockapi end attr_accessor :actor - # An optional key that is used to reference a specific workflow trigger request - # when issuing a [workflow cancellation](/send-notifications/canceling-workflows) - # request. Must be provided while triggering a workflow in order to enable - # subsequent cancellation. Should be unique across trigger requests to avoid - # unintentional cancellations. + # A key that is used to reference a specific workflow trigger request when issuing + # a [workflow cancellation](/send-notifications/canceling-workflows) request. Must + # be provided while triggering a workflow in order to enable subsequent + # cancellation. Should be unique across trigger requests to avoid unintentional + # cancellations. sig { returns(T.nilable(String)) } attr_accessor :cancellation_key @@ -98,11 +98,11 @@ module Knockapi # (string), an inline user request (object), or an inline object request, which is # determined by the presence of a `collection` property. actor: nil, - # An optional key that is used to reference a specific workflow trigger request - # when issuing a [workflow cancellation](/send-notifications/canceling-workflows) - # request. Must be provided while triggering a workflow in order to enable - # subsequent cancellation. Should be unique across trigger requests to avoid - # unintentional cancellations. + # A key that is used to reference a specific workflow trigger request when issuing + # a [workflow cancellation](/send-notifications/canceling-workflows) request. Must + # be provided while triggering a workflow in order to enable subsequent + # cancellation. Should be unique across trigger requests to avoid unintentional + # cancellations. cancellation_key: nil, # An optional map of data to pass into the workflow execution. There is a 10MB # limit on the size of the full `data` payload. Any individual string value diff --git a/rbi/knockapi/resources/objects.rbi b/rbi/knockapi/resources/objects.rbi index 97d049fc..97384573 100644 --- a/rbi/knockapi/resources/objects.rbi +++ b/rbi/knockapi/resources/objects.rbi @@ -532,6 +532,26 @@ module Knockapi ) end + # Unsets the preference set for the object, removing it entirely. + sig do + params( + collection: String, + object_id_: String, + id: String, + request_options: Knockapi::RequestOptions::OrHash + ).void + end + def unset_preferences( + # The collection this object belongs to. + collection, + # Unique identifier for the object. + object_id_, + # Unique identifier for the preference set. + id, + request_options: {} + ) + end + # @api private sig { params(client: Knockapi::Client).returns(T.attached_class) } def self.new(client:) diff --git a/rbi/knockapi/resources/users.rbi b/rbi/knockapi/resources/users.rbi index 6ed05eee..80f68df8 100644 --- a/rbi/knockapi/resources/users.rbi +++ b/rbi/knockapi/resources/users.rbi @@ -464,6 +464,23 @@ module Knockapi ) end + # Unsets the preference set for the user, removing it entirely. + sig do + params( + user_id: String, + id: String, + request_options: Knockapi::RequestOptions::OrHash + ).void + end + def unset_preferences( + # The unique identifier of the user. + user_id, + # Unique identifier for the preference set. + id, + request_options: {} + ) + end + # @api private sig { params(client: Knockapi::Client).returns(T.attached_class) } def self.new(client:) diff --git a/rbi/knockapi/resources/workflow_recipient_runs.rbi b/rbi/knockapi/resources/workflow_recipient_runs.rbi new file mode 100644 index 00000000..e3797e01 --- /dev/null +++ b/rbi/knockapi/resources/workflow_recipient_runs.rbi @@ -0,0 +1,79 @@ +# typed: strong + +module Knockapi + module Resources + # A workflow run represents an individual execution of a workflow for a specific + # recipient. + class WorkflowRecipientRuns + # Returns a paginated list of workflow recipient runs for the current environment. + sig do + params( + after: String, + before: String, + ending_at: Time, + has_errors: T::Boolean, + page_size: Integer, + recipient: + T.any( + String, + Knockapi::RecipientReference::ObjectReference::OrHash + ), + starting_at: Time, + status: + T::Array[ + Knockapi::WorkflowRecipientRunListParams::Status::OrSymbol + ], + tenant: String, + workflow: String, + request_options: Knockapi::RequestOptions::OrHash + ).returns( + Knockapi::Internal::ItemsCursor[Knockapi::WorkflowRecipientRun] + ) + end + def list( + # The cursor to fetch entries after. + after: nil, + # The cursor to fetch entries before. + before: nil, + # Limits the results to workflow recipient runs started before the given date. + ending_at: nil, + # Limits the results to workflow recipient runs that have errors. + has_errors: nil, + # The number of items per page (defaults to 50). + page_size: nil, + # Limits the results to workflow recipient runs for the given recipient. Accepts a + # user ID string or an object reference with `id` and `collection`. + recipient: nil, + # Limits the results to workflow recipient runs started after the given date. + starting_at: nil, + # Limits the results to workflow recipient runs with the given status. + status: nil, + # Limits the results to workflow recipient runs for the given tenant. + tenant: nil, + # Limits the results to workflow recipient runs for the given workflow key. + workflow: nil, + request_options: {} + ) + end + + # Returns a single workflow recipient run with its associated events. + sig do + params( + id: String, + request_options: Knockapi::RequestOptions::OrHash + ).returns(Knockapi::WorkflowRecipientRunDetail) + end + def get( + # The unique identifier for the workflow recipient run (per-recipient). + id, + request_options: {} + ) + end + + # @api private + sig { params(client: Knockapi::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end +end diff --git a/rbi/knockapi/resources/workflows.rbi b/rbi/knockapi/resources/workflows.rbi index a2224aeb..53cb0784 100644 --- a/rbi/knockapi/resources/workflows.rbi +++ b/rbi/knockapi/resources/workflows.rbi @@ -27,11 +27,11 @@ module Knockapi def cancel( # The key of the workflow to cancel. key, - # An optional key that is used to reference a specific workflow trigger request - # when issuing a [workflow cancellation](/send-notifications/canceling-workflows) - # request. Must be provided while triggering a workflow in order to enable - # subsequent cancellation. Should be unique across trigger requests to avoid - # unintentional cancellations. + # A key that is used to reference a specific workflow trigger request when issuing + # a [workflow cancellation](/send-notifications/canceling-workflows) request. Must + # be provided while triggering a workflow in order to enable subsequent + # cancellation. Should be unique across trigger requests to avoid unintentional + # cancellations. cancellation_key:, # A list of recipients to cancel the notification for. If omitted, cancels for all # recipients associated with the cancellation key. @@ -80,11 +80,11 @@ module Knockapi # (string), an inline user request (object), or an inline object request, which is # determined by the presence of a `collection` property. actor: nil, - # An optional key that is used to reference a specific workflow trigger request - # when issuing a [workflow cancellation](/send-notifications/canceling-workflows) - # request. Must be provided while triggering a workflow in order to enable - # subsequent cancellation. Should be unique across trigger requests to avoid - # unintentional cancellations. + # A key that is used to reference a specific workflow trigger request when issuing + # a [workflow cancellation](/send-notifications/canceling-workflows) request. Must + # be provided while triggering a workflow in order to enable subsequent + # cancellation. Should be unique across trigger requests to avoid unintentional + # cancellations. cancellation_key: nil, # An optional map of data to pass into the workflow execution. There is a 10MB # limit on the size of the full `data` payload. Any individual string value diff --git a/scripts/bootstrap b/scripts/bootstrap index 34878642..a5e1b80a 100755 --- a/scripts/bootstrap +++ b/scripts/bootstrap @@ -4,7 +4,7 @@ set -e cd -- "$(dirname -- "$0")/.." -if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ] && [ -t 0 ]; then +if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "${SKIP_BREW:-}" != "1" ] && [ -t 0 ]; then brew bundle check >/dev/null 2>&1 || { echo -n "==> Install Homebrew dependencies? (y/N): " read -r response diff --git a/scripts/mock b/scripts/mock index 4931f304..04d29019 100755 --- a/scripts/mock +++ b/scripts/mock @@ -22,9 +22,9 @@ echo "==> Starting mock server with URL ${URL}" # Run steady mock on the given spec if [ "$1" == "--daemon" ]; then # Pre-install the package so the download doesn't eat into the startup timeout - npm exec --package=@stdy/cli@0.19.7 -- steady --version + npm exec --package=@stdy/cli@0.22.1 -- steady --version - npm exec --package=@stdy/cli@0.19.7 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & + npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" @@ -48,5 +48,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stdy/cli@0.19.7 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" + npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index acff404e..ad94c14b 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! steady_is_running ; then echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.7 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.22.1 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" echo exit 1 diff --git a/sig/knockapi/client.rbs b/sig/knockapi/client.rbs index 3b519553..c4731bb3 100644 --- a/sig/knockapi/client.rbs +++ b/sig/knockapi/client.rbs @@ -30,6 +30,8 @@ module Knockapi attr_reader workflows: Knockapi::Resources::Workflows + attr_reader workflow_recipient_runs: Knockapi::Resources::WorkflowRecipientRuns + attr_reader schedules: Knockapi::Resources::Schedules attr_reader channels: Knockapi::Resources::Channels diff --git a/sig/knockapi/internal/util.rbs b/sig/knockapi/internal/util.rbs index f0ea6692..486b0dcb 100644 --- a/sig/knockapi/internal/util.rbs +++ b/sig/knockapi/internal/util.rbs @@ -45,8 +45,12 @@ module Knockapi -> top? } -> top? + RFC_3986_NOT_PCHARS: Regexp + def self?.uri_origin: (URI::Generic uri) -> String + def self?.encode_path: (String | Integer path) -> String + def self?.interpolate_path: (String | ::Array[String] path) -> String def self?.decode_query: (String? query) -> ::Hash[String, ::Array[String]] diff --git a/sig/knockapi/models.rbs b/sig/knockapi/models.rbs index 7fd3a3ac..84bb1e4f 100644 --- a/sig/knockapi/models.rbs +++ b/sig/knockapi/models.rbs @@ -95,6 +95,8 @@ module Knockapi class ObjectUnsetChannelDataParams = Knockapi::Models::ObjectUnsetChannelDataParams + class ObjectUnsetPreferencesParams = Knockapi::Models::ObjectUnsetPreferencesParams + class PageInfo = Knockapi::Models::PageInfo module Providers = Knockapi::Models::Providers @@ -165,9 +167,21 @@ module Knockapi class UserUnsetChannelDataParams = Knockapi::Models::UserUnsetChannelDataParams + class UserUnsetPreferencesParams = Knockapi::Models::UserUnsetPreferencesParams + class UserUpdateParams = Knockapi::Models::UserUpdateParams class WorkflowCancelParams = Knockapi::Models::WorkflowCancelParams + class WorkflowRecipientRun = Knockapi::Models::WorkflowRecipientRun + + class WorkflowRecipientRunDetail = Knockapi::Models::WorkflowRecipientRunDetail + + class WorkflowRecipientRunEvent = Knockapi::Models::WorkflowRecipientRunEvent + + class WorkflowRecipientRunGetParams = Knockapi::Models::WorkflowRecipientRunGetParams + + class WorkflowRecipientRunListParams = Knockapi::Models::WorkflowRecipientRunListParams + class WorkflowTriggerParams = Knockapi::Models::WorkflowTriggerParams end diff --git a/sig/knockapi/models/condition.rbs b/sig/knockapi/models/condition.rbs index 872b85bc..4e7ec257 100644 --- a/sig/knockapi/models/condition.rbs +++ b/sig/knockapi/models/condition.rbs @@ -40,6 +40,7 @@ module Knockapi | :exists | :not_exists | :contains_all + | :not_contains_all | :is_timestamp | :is_not_timestamp | :is_timestamp_on_or_after @@ -67,6 +68,7 @@ module Knockapi EXISTS: :exists NOT_EXISTS: :not_exists CONTAINS_ALL: :contains_all + NOT_CONTAINS_ALL: :not_contains_all IS_TIMESTAMP: :is_timestamp IS_NOT_TIMESTAMP: :is_not_timestamp IS_TIMESTAMP_ON_OR_AFTER: :is_timestamp_on_or_after diff --git a/sig/knockapi/models/message_event.rbs b/sig/knockapi/models/message_event.rbs index f283cac6..3c8c64a5 100644 --- a/sig/knockapi/models/message_event.rbs +++ b/sig/knockapi/models/message_event.rbs @@ -42,42 +42,42 @@ module Knockapi } type type_ = - :"message.archived" - | :"message.bounced" - | :"message.created" + :"message.read" + | :"message.sent" + | :"message.seen" + | :"message.archived" + | :"message.queued" | :"message.delivered" + | :"message.not_sent" + | :"message.bounced" + | :"message.undelivered" | :"message.delivery_attempted" - | :"message.interacted" | :"message.link_clicked" - | :"message.not_sent" - | :"message.queued" - | :"message.read" - | :"message.seen" - | :"message.sent" + | :"message.interacted" | :"message.unarchived" - | :"message.undelivered" - | :"message.unread" | :"message.unseen" + | :"message.unread" + | :"message.created" module Type extend Knockapi::Internal::Type::Enum + MESSAGE_READ: :"message.read" + MESSAGE_SENT: :"message.sent" + MESSAGE_SEEN: :"message.seen" MESSAGE_ARCHIVED: :"message.archived" - MESSAGE_BOUNCED: :"message.bounced" - MESSAGE_CREATED: :"message.created" + MESSAGE_QUEUED: :"message.queued" MESSAGE_DELIVERED: :"message.delivered" + MESSAGE_NOT_SENT: :"message.not_sent" + MESSAGE_BOUNCED: :"message.bounced" + MESSAGE_UNDELIVERED: :"message.undelivered" MESSAGE_DELIVERY_ATTEMPTED: :"message.delivery_attempted" - MESSAGE_INTERACTED: :"message.interacted" MESSAGE_LINK_CLICKED: :"message.link_clicked" - MESSAGE_NOT_SENT: :"message.not_sent" - MESSAGE_QUEUED: :"message.queued" - MESSAGE_READ: :"message.read" - MESSAGE_SEEN: :"message.seen" - MESSAGE_SENT: :"message.sent" + MESSAGE_INTERACTED: :"message.interacted" MESSAGE_UNARCHIVED: :"message.unarchived" - MESSAGE_UNDELIVERED: :"message.undelivered" - MESSAGE_UNREAD: :"message.unread" MESSAGE_UNSEEN: :"message.unseen" + MESSAGE_UNREAD: :"message.unread" + MESSAGE_CREATED: :"message.created" def self?.values: -> ::Array[Knockapi::Models::MessageEvent::type_] end diff --git a/sig/knockapi/models/object_unset_preferences_params.rbs b/sig/knockapi/models/object_unset_preferences_params.rbs new file mode 100644 index 00000000..49d3676f --- /dev/null +++ b/sig/knockapi/models/object_unset_preferences_params.rbs @@ -0,0 +1,32 @@ +module Knockapi + module Models + type object_unset_preferences_params = + { collection: String, object_id_: String, id: String } + & Knockapi::Internal::Type::request_parameters + + class ObjectUnsetPreferencesParams < Knockapi::Internal::Type::BaseModel + extend Knockapi::Internal::Type::RequestParameters::Converter + include Knockapi::Internal::Type::RequestParameters + + attr_accessor collection: String + + attr_accessor object_id_: String + + attr_accessor id: String + + def initialize: ( + collection: String, + object_id_: String, + id: String, + ?request_options: Knockapi::request_opts + ) -> void + + def to_hash: -> { + collection: String, + object_id_: String, + id: String, + request_options: Knockapi::RequestOptions + } + end + end +end diff --git a/sig/knockapi/models/providers/ms_team_check_auth_response.rbs b/sig/knockapi/models/providers/ms_team_check_auth_response.rbs index f63487d1..79d2642a 100644 --- a/sig/knockapi/models/providers/ms_team_check_auth_response.rbs +++ b/sig/knockapi/models/providers/ms_team_check_auth_response.rbs @@ -17,16 +17,27 @@ module Knockapi connection: Knockapi::Models::Providers::MsTeamCheckAuthResponse::Connection } - type connection = { ok: bool, reason: String? } + type connection = + { ok: bool, ms_teams_tenant_id: String?, reason: String? } class Connection < Knockapi::Internal::Type::BaseModel attr_accessor ok: bool - attr_accessor reason: String? + attr_accessor ms_teams_tenant_id: String? - def initialize: (ok: bool, ?reason: String?) -> void + attr_accessor reason: String? - def to_hash: -> { ok: bool, reason: String? } + def initialize: ( + ok: bool, + ?ms_teams_tenant_id: String?, + ?reason: String? + ) -> void + + def to_hash: -> { + ok: bool, + ms_teams_tenant_id: String?, + reason: String? + } end end end diff --git a/sig/knockapi/models/user_unset_preferences_params.rbs b/sig/knockapi/models/user_unset_preferences_params.rbs new file mode 100644 index 00000000..36f012de --- /dev/null +++ b/sig/knockapi/models/user_unset_preferences_params.rbs @@ -0,0 +1,28 @@ +module Knockapi + module Models + type user_unset_preferences_params = + { user_id: String, id: String } + & Knockapi::Internal::Type::request_parameters + + class UserUnsetPreferencesParams < Knockapi::Internal::Type::BaseModel + extend Knockapi::Internal::Type::RequestParameters::Converter + include Knockapi::Internal::Type::RequestParameters + + attr_accessor user_id: String + + attr_accessor id: String + + def initialize: ( + user_id: String, + id: String, + ?request_options: Knockapi::request_opts + ) -> void + + def to_hash: -> { + user_id: String, + id: String, + request_options: Knockapi::RequestOptions + } + end + end +end diff --git a/sig/knockapi/models/users/guide_get_channel_response.rbs b/sig/knockapi/models/users/guide_get_channel_response.rbs index f2dbaae6..79ca3503 100644 --- a/sig/knockapi/models/users/guide_get_channel_response.rbs +++ b/sig/knockapi/models/users/guide_get_channel_response.rbs @@ -41,6 +41,7 @@ module Knockapi active: bool, bypass_global_group_limit: bool, channel_id: String, + dashboard_url: String, inserted_at: Time, key: String, semver: String, @@ -82,6 +83,10 @@ module Knockapi def channel_id=: (String) -> String + attr_reader dashboard_url: String? + + def dashboard_url=: (String) -> String + attr_reader inserted_at: Time? def inserted_at=: (Time) -> Time @@ -116,6 +121,7 @@ module Knockapi ?active: bool, ?bypass_global_group_limit: bool, ?channel_id: String, + ?dashboard_url: String, ?inserted_at: Time, ?key: String, ?semver: String, @@ -132,6 +138,7 @@ module Knockapi active: bool, bypass_global_group_limit: bool, channel_id: String, + dashboard_url: String, inserted_at: Time, key: String, semver: String, diff --git a/sig/knockapi/models/workflow_recipient_run.rbs b/sig/knockapi/models/workflow_recipient_run.rbs new file mode 100644 index 00000000..48a7eb86 --- /dev/null +++ b/sig/knockapi/models/workflow_recipient_run.rbs @@ -0,0 +1,146 @@ +module Knockapi + module Models + type workflow_recipient_run = + { + id: String, + _typename: String, + inserted_at: Time, + recipient: Knockapi::Models::recipient_reference, + status: Knockapi::Models::WorkflowRecipientRun::status, + trigger_source: Knockapi::WorkflowRecipientRun::TriggerSource, + updated_at: Time, + workflow: String, + workflow_run_id: String, + actor: Knockapi::Models::recipient_reference?, + error_count: Integer, + tenant: String? + } + + class WorkflowRecipientRun < Knockapi::Internal::Type::BaseModel + attr_accessor id: String + + attr_accessor _typename: String + + attr_accessor inserted_at: Time + + attr_accessor recipient: Knockapi::Models::recipient_reference + + attr_accessor status: Knockapi::Models::WorkflowRecipientRun::status + + attr_accessor trigger_source: Knockapi::WorkflowRecipientRun::TriggerSource + + attr_accessor updated_at: Time + + attr_accessor workflow: String + + attr_accessor workflow_run_id: String + + attr_accessor actor: Knockapi::Models::recipient_reference? + + attr_reader error_count: Integer? + + def error_count=: (Integer) -> Integer + + attr_accessor tenant: String? + + def initialize: ( + id: String, + _typename: String, + inserted_at: Time, + recipient: Knockapi::Models::recipient_reference, + status: Knockapi::Models::WorkflowRecipientRun::status, + trigger_source: Knockapi::WorkflowRecipientRun::TriggerSource, + updated_at: Time, + workflow: String, + workflow_run_id: String, + ?actor: Knockapi::Models::recipient_reference?, + ?error_count: Integer, + ?tenant: String? + ) -> void + + def to_hash: -> { + id: String, + _typename: String, + inserted_at: Time, + recipient: Knockapi::Models::recipient_reference, + status: Knockapi::Models::WorkflowRecipientRun::status, + trigger_source: Knockapi::WorkflowRecipientRun::TriggerSource, + updated_at: Time, + workflow: String, + workflow_run_id: String, + actor: Knockapi::Models::recipient_reference?, + error_count: Integer, + tenant: String? + } + + type status = :queued | :processing | :paused | :completed | :cancelled + + module Status + extend Knockapi::Internal::Type::Enum + + QUEUED: :queued + PROCESSING: :processing + PAUSED: :paused + COMPLETED: :completed + CANCELLED: :cancelled + + def self?.values: -> ::Array[Knockapi::Models::WorkflowRecipientRun::status] + end + + type trigger_source = + { + type: Knockapi::Models::WorkflowRecipientRun::TriggerSource::type_, + audience_key: String?, + cancellation_key: String?, + schedule_id: String? + } + + class TriggerSource < Knockapi::Internal::Type::BaseModel + attr_accessor type: Knockapi::Models::WorkflowRecipientRun::TriggerSource::type_ + + attr_accessor audience_key: String? + + attr_accessor cancellation_key: String? + + attr_accessor schedule_id: String? + + def initialize: ( + type: Knockapi::Models::WorkflowRecipientRun::TriggerSource::type_, + ?audience_key: String?, + ?cancellation_key: String?, + ?schedule_id: String? + ) -> void + + def to_hash: -> { + type: Knockapi::Models::WorkflowRecipientRun::TriggerSource::type_, + audience_key: String?, + cancellation_key: String?, + schedule_id: String? + } + + type type_ = + :api + | :audience + | :schedule + | :broadcast + | :workflow_step + | :integration + | :rehearsal + + module Type + extend Knockapi::Internal::Type::Enum + + API: :api + AUDIENCE: :audience + SCHEDULE: :schedule + BROADCAST: :broadcast + WORKFLOW_STEP: :workflow_step + INTEGRATION: :integration + REHEARSAL: :rehearsal + + def self?.values: -> ::Array[Knockapi::Models::WorkflowRecipientRun::TriggerSource::type_] + end + end + end + end +end diff --git a/sig/knockapi/models/workflow_recipient_run_detail.rbs b/sig/knockapi/models/workflow_recipient_run_detail.rbs new file mode 100644 index 00000000..277332bc --- /dev/null +++ b/sig/knockapi/models/workflow_recipient_run_detail.rbs @@ -0,0 +1,20 @@ +module Knockapi + module Models + type workflow_recipient_run_detail = + { events: ::Array[Knockapi::WorkflowRecipientRunEvent] } + + class WorkflowRecipientRunDetail < Knockapi::Models::WorkflowRecipientRun + def events: -> ::Array[Knockapi::WorkflowRecipientRunEvent] + + def events=: ( + ::Array[Knockapi::WorkflowRecipientRunEvent] _ + ) -> ::Array[Knockapi::WorkflowRecipientRunEvent] + + def initialize: ( + events: ::Array[Knockapi::WorkflowRecipientRunEvent] + ) -> void + + def to_hash: -> { events: ::Array[Knockapi::WorkflowRecipientRunEvent] } + end + end +end diff --git a/sig/knockapi/models/workflow_recipient_run_event.rbs b/sig/knockapi/models/workflow_recipient_run_event.rbs new file mode 100644 index 00000000..f55ca13f --- /dev/null +++ b/sig/knockapi/models/workflow_recipient_run_event.rbs @@ -0,0 +1,73 @@ +module Knockapi + module Models + type workflow_recipient_run_event = + { + id: String, + _typename: String, + event: String, + inserted_at: Time, + status: Knockapi::Models::WorkflowRecipientRunEvent::status, + attempt: Integer, + data: ::Hash[Symbol, top]?, + step_ref: String?, + step_type: String? + } + + class WorkflowRecipientRunEvent < Knockapi::Internal::Type::BaseModel + attr_accessor id: String + + attr_accessor _typename: String + + attr_accessor event: String + + attr_accessor inserted_at: Time + + attr_accessor status: Knockapi::Models::WorkflowRecipientRunEvent::status + + attr_reader attempt: Integer? + + def attempt=: (Integer) -> Integer + + attr_accessor data: ::Hash[Symbol, top]? + + attr_accessor step_ref: String? + + attr_accessor step_type: String? + + def initialize: ( + id: String, + _typename: String, + event: String, + inserted_at: Time, + status: Knockapi::Models::WorkflowRecipientRunEvent::status, + ?attempt: Integer, + ?data: ::Hash[Symbol, top]?, + ?step_ref: String?, + ?step_type: String? + ) -> void + + def to_hash: -> { + id: String, + _typename: String, + event: String, + inserted_at: Time, + status: Knockapi::Models::WorkflowRecipientRunEvent::status, + attempt: Integer, + data: ::Hash[Symbol, top]?, + step_ref: String?, + step_type: String? + } + + type status = :ok | :error + + module Status + extend Knockapi::Internal::Type::Enum + + OK: :ok + ERROR: :error + + def self?.values: -> ::Array[Knockapi::Models::WorkflowRecipientRunEvent::status] + end + end + end +end diff --git a/sig/knockapi/models/workflow_recipient_run_get_params.rbs b/sig/knockapi/models/workflow_recipient_run_get_params.rbs new file mode 100644 index 00000000..268bc549 --- /dev/null +++ b/sig/knockapi/models/workflow_recipient_run_get_params.rbs @@ -0,0 +1,20 @@ +module Knockapi + module Models + type workflow_recipient_run_get_params = + { id: String } & Knockapi::Internal::Type::request_parameters + + class WorkflowRecipientRunGetParams < Knockapi::Internal::Type::BaseModel + extend Knockapi::Internal::Type::RequestParameters::Converter + include Knockapi::Internal::Type::RequestParameters + + attr_accessor id: String + + def initialize: ( + id: String, + ?request_options: Knockapi::request_opts + ) -> void + + def to_hash: -> { id: String, request_options: Knockapi::RequestOptions } + end + end +end diff --git a/sig/knockapi/models/workflow_recipient_run_list_params.rbs b/sig/knockapi/models/workflow_recipient_run_list_params.rbs new file mode 100644 index 00000000..bae2ea07 --- /dev/null +++ b/sig/knockapi/models/workflow_recipient_run_list_params.rbs @@ -0,0 +1,109 @@ +module Knockapi + module Models + type workflow_recipient_run_list_params = + { + after: String, + before: String, + ending_at: Time, + has_errors: bool, + page_size: Integer, + recipient: Knockapi::Models::recipient_reference, + starting_at: Time, + status: ::Array[Knockapi::Models::WorkflowRecipientRunListParams::status], + tenant: String, + workflow: String + } + & Knockapi::Internal::Type::request_parameters + + class WorkflowRecipientRunListParams < Knockapi::Internal::Type::BaseModel + extend Knockapi::Internal::Type::RequestParameters::Converter + include Knockapi::Internal::Type::RequestParameters + + attr_reader after: String? + + def after=: (String) -> String + + attr_reader before: String? + + def before=: (String) -> String + + attr_reader ending_at: Time? + + def ending_at=: (Time) -> Time + + attr_reader has_errors: bool? + + def has_errors=: (bool) -> bool + + attr_reader page_size: Integer? + + def page_size=: (Integer) -> Integer + + attr_reader recipient: Knockapi::Models::recipient_reference? + + def recipient=: ( + Knockapi::Models::recipient_reference + ) -> Knockapi::Models::recipient_reference + + attr_reader starting_at: Time? + + def starting_at=: (Time) -> Time + + attr_reader status: ::Array[Knockapi::Models::WorkflowRecipientRunListParams::status]? + + def status=: ( + ::Array[Knockapi::Models::WorkflowRecipientRunListParams::status] + ) -> ::Array[Knockapi::Models::WorkflowRecipientRunListParams::status] + + attr_reader tenant: String? + + def tenant=: (String) -> String + + attr_reader workflow: String? + + def workflow=: (String) -> String + + def initialize: ( + ?after: String, + ?before: String, + ?ending_at: Time, + ?has_errors: bool, + ?page_size: Integer, + ?recipient: Knockapi::Models::recipient_reference, + ?starting_at: Time, + ?status: ::Array[Knockapi::Models::WorkflowRecipientRunListParams::status], + ?tenant: String, + ?workflow: String, + ?request_options: Knockapi::request_opts + ) -> void + + def to_hash: -> { + after: String, + before: String, + ending_at: Time, + has_errors: bool, + page_size: Integer, + recipient: Knockapi::Models::recipient_reference, + starting_at: Time, + status: ::Array[Knockapi::Models::WorkflowRecipientRunListParams::status], + tenant: String, + workflow: String, + request_options: Knockapi::RequestOptions + } + + type status = :queued | :processing | :paused | :completed | :cancelled + + module Status + extend Knockapi::Internal::Type::Enum + + QUEUED: :queued + PROCESSING: :processing + PAUSED: :paused + COMPLETED: :completed + CANCELLED: :cancelled + + def self?.values: -> ::Array[Knockapi::Models::WorkflowRecipientRunListParams::status] + end + end + end +end diff --git a/sig/knockapi/resources/objects.rbs b/sig/knockapi/resources/objects.rbs index 71d80f3e..7bd42627 100644 --- a/sig/knockapi/resources/objects.rbs +++ b/sig/knockapi/resources/objects.rbs @@ -142,6 +142,13 @@ module Knockapi ?request_options: Knockapi::request_opts ) -> nil + def unset_preferences: ( + String collection, + String object_id_, + String id, + ?request_options: Knockapi::request_opts + ) -> nil + def initialize: (client: Knockapi::Client) -> void end end diff --git a/sig/knockapi/resources/users.rbs b/sig/knockapi/resources/users.rbs index 39321e6d..1f316317 100644 --- a/sig/knockapi/resources/users.rbs +++ b/sig/knockapi/resources/users.rbs @@ -127,6 +127,12 @@ module Knockapi ?request_options: Knockapi::request_opts ) -> nil + def unset_preferences: ( + String user_id, + String id, + ?request_options: Knockapi::request_opts + ) -> nil + def initialize: (client: Knockapi::Client) -> void end end diff --git a/sig/knockapi/resources/workflow_recipient_runs.rbs b/sig/knockapi/resources/workflow_recipient_runs.rbs new file mode 100644 index 00000000..1da6e025 --- /dev/null +++ b/sig/knockapi/resources/workflow_recipient_runs.rbs @@ -0,0 +1,26 @@ +module Knockapi + module Resources + class WorkflowRecipientRuns + def list: ( + ?after: String, + ?before: String, + ?ending_at: Time, + ?has_errors: bool, + ?page_size: Integer, + ?recipient: Knockapi::Models::recipient_reference, + ?starting_at: Time, + ?status: ::Array[Knockapi::Models::WorkflowRecipientRunListParams::status], + ?tenant: String, + ?workflow: String, + ?request_options: Knockapi::request_opts + ) -> Knockapi::Internal::ItemsCursor[Knockapi::WorkflowRecipientRun] + + def get: ( + String id, + ?request_options: Knockapi::request_opts + ) -> Knockapi::WorkflowRecipientRunDetail + + def initialize: (client: Knockapi::Client) -> void + end + end +end diff --git a/test/knockapi/client_test.rb b/test/knockapi/client_test.rb index 1c25365c..19dd72e5 100644 --- a/test/knockapi/client_test.rb +++ b/test/knockapi/client_test.rb @@ -200,8 +200,8 @@ def test_client_redirect_307 assert_equal(recorded.method, _1.method) assert_equal(recorded.body, _1.body) assert_equal( - recorded.headers.transform_keys(&:downcase).fetch("content-type"), - _1.headers.transform_keys(&:downcase).fetch("content-type") + recorded.headers.transform_keys(&:downcase)["content-type"], + _1.headers.transform_keys(&:downcase)["content-type"] ) end end @@ -324,8 +324,9 @@ def test_default_headers knock.users.get("user_id") assert_requested(:any, /./) do |req| - headers = req.headers.transform_keys(&:downcase).fetch_values("accept", "content-type") - headers.each { refute_empty(_1) } + headers = req.headers.transform_keys(&:downcase) + expected = req.body.nil? ? ["accept"] : %w[accept content-type] + headers.fetch_values(*expected).each { refute_empty(_1) } end end end diff --git a/test/knockapi/resources/objects_test.rb b/test/knockapi/resources/objects_test.rb index d44ea708..da6524f5 100644 --- a/test/knockapi/resources/objects_test.rb +++ b/test/knockapi/resources/objects_test.rb @@ -286,4 +286,12 @@ def test_unset_channel_data response => nil end end + + def test_unset_preferences + response = @knock.objects.unset_preferences("collection", "object_id", "default") + + assert_pattern do + response => nil + end + end end diff --git a/test/knockapi/resources/users_test.rb b/test/knockapi/resources/users_test.rb index c4b25eeb..44bd2037 100644 --- a/test/knockapi/resources/users_test.rb +++ b/test/knockapi/resources/users_test.rb @@ -298,4 +298,12 @@ def test_unset_channel_data response => nil end end + + def test_unset_preferences + response = @knock.users.unset_preferences("user_id", "default") + + assert_pattern do + response => nil + end + end end diff --git a/test/knockapi/resources/workflow_recipient_runs_test.rb b/test/knockapi/resources/workflow_recipient_runs_test.rb new file mode 100644 index 00000000..5222d5e8 --- /dev/null +++ b/test/knockapi/resources/workflow_recipient_runs_test.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class Knockapi::Test::Resources::WorkflowRecipientRunsTest < Knockapi::Test::ResourceTest + def test_list + response = @knock.workflow_recipient_runs.list + + assert_pattern do + response => Knockapi::Internal::ItemsCursor + end + + row = response.to_enum.first + return if row.nil? + + assert_pattern do + row => Knockapi::WorkflowRecipientRun + end + + assert_pattern do + row => { + id: String, + _typename: String, + inserted_at: Time, + recipient: Knockapi::RecipientReference, + status: Knockapi::WorkflowRecipientRun::Status, + trigger_source: Knockapi::WorkflowRecipientRun::TriggerSource, + updated_at: Time, + workflow: String, + workflow_run_id: String, + actor: Knockapi::RecipientReference | nil, + error_count: Integer | nil, + tenant: String | nil + } + end + end + + def test_get + response = @knock.workflow_recipient_runs.get("id") + + assert_pattern do + response => Knockapi::WorkflowRecipientRunDetail + end + end +end