Skip to content

Commit 9b272e8

Browse files
feat(api): added new unset preferences methods
1 parent 4ff46f6 commit 9b272e8

19 files changed

Lines changed: 343 additions & 2 deletions

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 90
1+
configured_endpoints: 92
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/knock%2Fknock-f7658bcdf4b85c3c7b283f0dc216e7eb425d4ff258674fa79f6caa0eeb340b5e.yml
33
openapi_spec_hash: c80f2985521f9fc3cb931940915e6a99
4-
config_hash: 32503026a45db991d0d102f25af40a77
4+
config_hash: a3056fe062e62c7ca4d3931ccf3f6d06

lib/knockapi.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
require_relative "knockapi/models/object_set_params"
133133
require_relative "knockapi/models/object_set_preferences_params"
134134
require_relative "knockapi/models/object_unset_channel_data_params"
135+
require_relative "knockapi/models/object_unset_preferences_params"
135136
require_relative "knockapi/models/page_info"
136137
require_relative "knockapi/models/providers/ms_team_check_auth_params"
137138
require_relative "knockapi/models/providers/ms_team_check_auth_response"
@@ -214,6 +215,7 @@
214215
require_relative "knockapi/models/user_set_channel_data_params"
215216
require_relative "knockapi/models/user_set_preferences_params"
216217
require_relative "knockapi/models/user_unset_channel_data_params"
218+
require_relative "knockapi/models/user_unset_preferences_params"
217219
require_relative "knockapi/models/user_update_params"
218220
require_relative "knockapi/models/workflow_cancel_params"
219221
require_relative "knockapi/models/workflow_trigger_params"

lib/knockapi/models.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ module Knockapi
135135

136136
ObjectUnsetChannelDataParams = Knockapi::Models::ObjectUnsetChannelDataParams
137137

138+
ObjectUnsetPreferencesParams = Knockapi::Models::ObjectUnsetPreferencesParams
139+
138140
PageInfo = Knockapi::Models::PageInfo
139141

140142
Providers = Knockapi::Models::Providers
@@ -205,6 +207,8 @@ module Knockapi
205207

206208
UserUnsetChannelDataParams = Knockapi::Models::UserUnsetChannelDataParams
207209

210+
UserUnsetPreferencesParams = Knockapi::Models::UserUnsetPreferencesParams
211+
208212
UserUpdateParams = Knockapi::Models::UserUpdateParams
209213

210214
WorkflowCancelParams = Knockapi::Models::WorkflowCancelParams
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# frozen_string_literal: true
2+
3+
module Knockapi
4+
module Models
5+
# @see Knockapi::Resources::Objects#unset_preferences
6+
class ObjectUnsetPreferencesParams < Knockapi::Internal::Type::BaseModel
7+
extend Knockapi::Internal::Type::RequestParameters::Converter
8+
include Knockapi::Internal::Type::RequestParameters
9+
10+
# @!attribute collection
11+
#
12+
# @return [String]
13+
required :collection, String
14+
15+
# @!attribute object_id_
16+
#
17+
# @return [String]
18+
required :object_id_, String
19+
20+
# @!attribute id
21+
#
22+
# @return [String]
23+
required :id, String
24+
25+
# @!method initialize(collection:, object_id_:, id:, request_options: {})
26+
# @param collection [String]
27+
# @param object_id_ [String]
28+
# @param id [String]
29+
# @param request_options [Knockapi::RequestOptions, Hash{Symbol=>Object}]
30+
end
31+
end
32+
end
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# frozen_string_literal: true
2+
3+
module Knockapi
4+
module Models
5+
# @see Knockapi::Resources::Users#unset_preferences
6+
class UserUnsetPreferencesParams < Knockapi::Internal::Type::BaseModel
7+
extend Knockapi::Internal::Type::RequestParameters::Converter
8+
include Knockapi::Internal::Type::RequestParameters
9+
10+
# @!attribute user_id
11+
#
12+
# @return [String]
13+
required :user_id, String
14+
15+
# @!attribute id
16+
#
17+
# @return [String]
18+
required :id, String
19+
20+
# @!method initialize(user_id:, id:, request_options: {})
21+
# @param user_id [String]
22+
# @param id [String]
23+
# @param request_options [Knockapi::RequestOptions, Hash{Symbol=>Object}]
24+
end
25+
end
26+
end

lib/knockapi/resources/objects.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,30 @@ def unset_channel_data(collection, object_id_, channel_id, params = {})
503503
)
504504
end
505505

506+
# Unsets the preference set for the object, removing it entirely.
507+
#
508+
# @overload unset_preferences(collection, object_id_, id, request_options: {})
509+
#
510+
# @param collection [String] The collection this object belongs to.
511+
#
512+
# @param object_id_ [String] Unique identifier for the object.
513+
#
514+
# @param id [String] Unique identifier for the preference set.
515+
#
516+
# @param request_options [Knockapi::RequestOptions, Hash{Symbol=>Object}, nil]
517+
#
518+
# @return [nil]
519+
#
520+
# @see Knockapi::Models::ObjectUnsetPreferencesParams
521+
def unset_preferences(collection, object_id_, id, params = {})
522+
@client.request(
523+
method: :delete,
524+
path: ["v1/objects/%1$s/%2$s/preferences/%3$s", collection, object_id_, id],
525+
model: NilClass,
526+
options: params[:request_options]
527+
)
528+
end
529+
506530
# @api private
507531
#
508532
# @param client [Knockapi::Client]

lib/knockapi/resources/users.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,28 @@ def unset_channel_data(user_id, channel_id, params = {})
449449
)
450450
end
451451

452+
# Unsets the preference set for the user, removing it entirely.
453+
#
454+
# @overload unset_preferences(user_id, id, request_options: {})
455+
#
456+
# @param user_id [String] The unique identifier of the user.
457+
#
458+
# @param id [String] Unique identifier for the preference set.
459+
#
460+
# @param request_options [Knockapi::RequestOptions, Hash{Symbol=>Object}, nil]
461+
#
462+
# @return [nil]
463+
#
464+
# @see Knockapi::Models::UserUnsetPreferencesParams
465+
def unset_preferences(user_id, id, params = {})
466+
@client.request(
467+
method: :delete,
468+
path: ["v1/users/%1$s/preferences/%2$s", user_id, id],
469+
model: NilClass,
470+
options: params[:request_options]
471+
)
472+
end
473+
452474
# @api private
453475
#
454476
# @param client [Knockapi::Client]

rbi/knockapi/models.rbi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ module Knockapi
101101

102102
ObjectUnsetChannelDataParams = Knockapi::Models::ObjectUnsetChannelDataParams
103103

104+
ObjectUnsetPreferencesParams = Knockapi::Models::ObjectUnsetPreferencesParams
105+
104106
PageInfo = Knockapi::Models::PageInfo
105107

106108
Providers = Knockapi::Models::Providers
@@ -171,6 +173,8 @@ module Knockapi
171173

172174
UserUnsetChannelDataParams = Knockapi::Models::UserUnsetChannelDataParams
173175

176+
UserUnsetPreferencesParams = Knockapi::Models::UserUnsetPreferencesParams
177+
174178
UserUpdateParams = Knockapi::Models::UserUpdateParams
175179

176180
WorkflowCancelParams = Knockapi::Models::WorkflowCancelParams
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# typed: strong
2+
3+
module Knockapi
4+
module Models
5+
class ObjectUnsetPreferencesParams < Knockapi::Internal::Type::BaseModel
6+
extend Knockapi::Internal::Type::RequestParameters::Converter
7+
include Knockapi::Internal::Type::RequestParameters
8+
9+
OrHash =
10+
T.type_alias do
11+
T.any(
12+
Knockapi::ObjectUnsetPreferencesParams,
13+
Knockapi::Internal::AnyHash
14+
)
15+
end
16+
17+
sig { returns(String) }
18+
attr_accessor :collection
19+
20+
sig { returns(String) }
21+
attr_accessor :object_id_
22+
23+
sig { returns(String) }
24+
attr_accessor :id
25+
26+
sig do
27+
params(
28+
collection: String,
29+
object_id_: String,
30+
id: String,
31+
request_options: Knockapi::RequestOptions::OrHash
32+
).returns(T.attached_class)
33+
end
34+
def self.new(collection:, object_id_:, id:, request_options: {})
35+
end
36+
37+
sig do
38+
override.returns(
39+
{
40+
collection: String,
41+
object_id_: String,
42+
id: String,
43+
request_options: Knockapi::RequestOptions
44+
}
45+
)
46+
end
47+
def to_hash
48+
end
49+
end
50+
end
51+
end
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# typed: strong
2+
3+
module Knockapi
4+
module Models
5+
class UserUnsetPreferencesParams < Knockapi::Internal::Type::BaseModel
6+
extend Knockapi::Internal::Type::RequestParameters::Converter
7+
include Knockapi::Internal::Type::RequestParameters
8+
9+
OrHash =
10+
T.type_alias do
11+
T.any(
12+
Knockapi::UserUnsetPreferencesParams,
13+
Knockapi::Internal::AnyHash
14+
)
15+
end
16+
17+
sig { returns(String) }
18+
attr_accessor :user_id
19+
20+
sig { returns(String) }
21+
attr_accessor :id
22+
23+
sig do
24+
params(
25+
user_id: String,
26+
id: String,
27+
request_options: Knockapi::RequestOptions::OrHash
28+
).returns(T.attached_class)
29+
end
30+
def self.new(user_id:, id:, request_options: {})
31+
end
32+
33+
sig do
34+
override.returns(
35+
{
36+
user_id: String,
37+
id: String,
38+
request_options: Knockapi::RequestOptions
39+
}
40+
)
41+
end
42+
def to_hash
43+
end
44+
end
45+
end
46+
end

0 commit comments

Comments
 (0)