Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.35.0"
".": "1.36.0"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -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: 92
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/knock%2Fknock-f7658bcdf4b85c3c7b283f0dc216e7eb425d4ff258674fa79f6caa0eeb340b5e.yml
openapi_spec_hash: c80f2985521f9fc3cb931940915e6a99
config_hash: a3056fe062e62c7ca4d3931ccf3f6d06
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Changelog

## 1.36.0 (2026-04-02)

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))


### Bug Fixes

* align path encoding with RFC 3986 section 3.3 ([3e2268d](https://github.com/knocklabs/knock-ruby/commit/3e2268d3e0547fa66ad253e35c86da963cc36215))
* variable name typo ([cde1131](https://github.com/knocklabs/knock-ruby/commit/cde113151eb2879204409723971653616876fdee))


### Chores

* **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))

## 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)
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GIT
PATH
remote: .
specs:
knockapi (1.35.0)
knockapi (1.36.0)
cgi
connection_pool

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ To use this gem, install via Bundler by adding the following to your application
<!-- x-release-please-start-version -->

```ruby
gem "knockapi", "~> 1.35.0"
gem "knockapi", "~> 1.36.0"
```

<!-- x-release-please-end -->
Expand Down
2 changes: 2 additions & 0 deletions lib/knockapi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,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"
Expand Down Expand Up @@ -214,6 +215,7 @@
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_trigger_params"
Expand Down
22 changes: 18 additions & 4 deletions lib/knockapi/internal/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
#
Expand All @@ -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<String>]
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions lib/knockapi/models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ module Knockapi

ObjectUnsetChannelDataParams = Knockapi::Models::ObjectUnsetChannelDataParams

ObjectUnsetPreferencesParams = Knockapi::Models::ObjectUnsetPreferencesParams

PageInfo = Knockapi::Models::PageInfo

Providers = Knockapi::Models::Providers
Expand Down Expand Up @@ -205,6 +207,8 @@ module Knockapi

UserUnsetChannelDataParams = Knockapi::Models::UserUnsetChannelDataParams

UserUnsetPreferencesParams = Knockapi::Models::UserUnsetPreferencesParams

UserUpdateParams = Knockapi::Models::UserUpdateParams

WorkflowCancelParams = Knockapi::Models::WorkflowCancelParams
Expand Down
32 changes: 32 additions & 0 deletions lib/knockapi/models/object_unset_preferences_params.rb
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions lib/knockapi/models/user_unset_preferences_params.rb
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions lib/knockapi/resources/objects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
22 changes: 22 additions & 0 deletions lib/knockapi/resources/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion lib/knockapi/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Knockapi
VERSION = "1.35.0"
VERSION = "1.36.0"
end
8 changes: 8 additions & 0 deletions rbi/knockapi/internal/util.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions rbi/knockapi/models.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ module Knockapi

ObjectUnsetChannelDataParams = Knockapi::Models::ObjectUnsetChannelDataParams

ObjectUnsetPreferencesParams = Knockapi::Models::ObjectUnsetPreferencesParams

PageInfo = Knockapi::Models::PageInfo

Providers = Knockapi::Models::Providers
Expand Down Expand Up @@ -171,6 +173,8 @@ module Knockapi

UserUnsetChannelDataParams = Knockapi::Models::UserUnsetChannelDataParams

UserUnsetPreferencesParams = Knockapi::Models::UserUnsetPreferencesParams

UserUpdateParams = Knockapi::Models::UserUpdateParams

WorkflowCancelParams = Knockapi::Models::WorkflowCancelParams
Expand Down
51 changes: 51 additions & 0 deletions rbi/knockapi/models/object_unset_preferences_params.rbi
Original file line number Diff line number Diff line change
@@ -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
Loading
Loading