Class: WorkOS::Connect
- Inherits:
-
Object
- Object
- WorkOS::Connect
- Defined in:
- lib/workos/connect.rb
Instance Method Summary collapse
-
#complete_oauth2(external_auth_id:, user:, user_consent_options: nil, request_options: {}) ⇒ WorkOS::ExternalAuthCompleteResponse
Complete external authentication.
-
#create_application(name:, application_type:, description: nil, scopes: nil, redirect_uris: nil, uses_pkce: nil, is_first_party: nil, organization_id: nil, request_options: {}) ⇒ WorkOS::ConnectApplication
Create a Connect Application.
-
#create_application_client_secret(id:, request_options: {}) ⇒ WorkOS::NewConnectApplicationSecret
Create a new client secret for a Connect Application.
-
#create_m2m_application(name:, organization_id:, description: nil, scopes: nil, request_options: {}) ⇒ WorkOS::ConnectApplication
Create m2m application.
-
#create_oauth_application(name:, is_first_party:, description: nil, scopes: nil, redirect_uris: nil, uses_pkce: nil, organization_id: nil, request_options: {}) ⇒ WorkOS::ConnectApplication
Create oauth application.
-
#delete_application(id:, request_options: {}) ⇒ void
Delete a Connect Application.
-
#delete_client_secret(id:, request_options: {}) ⇒ void
Delete a Client Secret.
-
#get_application(id:, request_options: {}) ⇒ WorkOS::ConnectApplication
Get a Connect Application.
-
#initialize(client) ⇒ Connect
constructor
A new instance of Connect.
-
#list_application_client_secrets(id:, request_options: {}) ⇒ Array<WorkOS::ApplicationCredentialsListItem>
List Client Secrets for a Connect Application.
-
#list_applications(before: nil, after: nil, limit: nil, order: "desc", organization_id: nil, request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::ConnectApplication>
List Connect Applications.
-
#update_application(id:, name: nil, description: nil, scopes: nil, redirect_uris: nil, request_options: {}) ⇒ WorkOS::ConnectApplication
Update a Connect Application.
Constructor Details
#initialize(client) ⇒ Connect
Returns a new instance of Connect.
9 10 11 |
# File 'lib/workos/connect.rb', line 9 def initialize(client) @client = client end |
Instance Method Details
#complete_oauth2(external_auth_id:, user:, user_consent_options: nil, request_options: {}) ⇒ WorkOS::ExternalAuthCompleteResponse
Complete external authentication
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/workos/connect.rb', line 19 def complete_oauth2( external_auth_id:, user:, user_consent_options: nil, request_options: {} ) body = { "external_auth_id" => external_auth_id, "user" => user, "user_consent_options" => }.compact response = @client.request( method: :post, path: "/authkit/oauth2/complete", auth: true, body: body, request_options: ) result = WorkOS::ExternalAuthCompleteResponse.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#create_application(name:, application_type:, description: nil, scopes: nil, redirect_uris: nil, uses_pkce: nil, is_first_party: nil, organization_id: nil, request_options: {}) ⇒ WorkOS::ConnectApplication
Create a Connect Application
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/workos/connect.rb', line 101 def create_application( name:, application_type:, description: nil, scopes: nil, redirect_uris: nil, uses_pkce: nil, is_first_party: nil, organization_id: nil, request_options: {} ) body = { "name" => name, "application_type" => application_type, "description" => description, "scopes" => scopes, "redirect_uris" => redirect_uris, "uses_pkce" => uses_pkce, "is_first_party" => is_first_party, "organization_id" => organization_id }.compact response = @client.request( method: :post, path: "/connect/applications", auth: true, body: body, request_options: ) result = WorkOS::ConnectApplication.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#create_application_client_secret(id:, request_options: {}) ⇒ WorkOS::NewConnectApplicationSecret
Create a new client secret for a Connect Application
297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
# File 'lib/workos/connect.rb', line 297 def create_application_client_secret( id:, request_options: {} ) response = @client.request( method: :post, path: "/connect/applications/#{WorkOS::Util.encode_path(id)}/client_secrets", auth: true, request_options: ) result = WorkOS::NewConnectApplicationSecret.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#create_m2m_application(name:, organization_id:, description: nil, scopes: nil, request_options: {}) ⇒ WorkOS::ConnectApplication
Create m2m application.
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/workos/connect.rb', line 181 def create_m2m_application( name:, organization_id:, description: nil, scopes: nil, request_options: {} ) body = { "application_type" => "m2m", "name" => name, "organization_id" => organization_id, "description" => description, "scopes" => scopes }.compact response = @client.request( method: :post, path: "/connect/applications", auth: true, body: body, request_options: ) WorkOS::ConnectApplication.new(response.body) end |
#create_oauth_application(name:, is_first_party:, description: nil, scopes: nil, redirect_uris: nil, uses_pkce: nil, organization_id: nil, request_options: {}) ⇒ WorkOS::ConnectApplication
Create oauth application.
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/workos/connect.rb', line 144 def create_oauth_application( name:, is_first_party:, description: nil, scopes: nil, redirect_uris: nil, uses_pkce: nil, organization_id: nil, request_options: {} ) body = { "application_type" => "oauth", "name" => name, "is_first_party" => is_first_party, "description" => description, "scopes" => scopes, "redirect_uris" => redirect_uris, "uses_pkce" => uses_pkce, "organization_id" => organization_id }.compact response = @client.request( method: :post, path: "/connect/applications", auth: true, body: body, request_options: ) WorkOS::ConnectApplication.new(response.body) end |
#delete_application(id:, request_options: {}) ⇒ void
This method returns an undefined value.
Delete a Connect Application
262 263 264 265 266 267 268 269 270 271 272 273 |
# File 'lib/workos/connect.rb', line 262 def delete_application( id:, request_options: {} ) @client.request( method: :delete, path: "/connect/applications/#{WorkOS::Util.encode_path(id)}", auth: true, request_options: ) nil end |
#delete_client_secret(id:, request_options: {}) ⇒ void
This method returns an undefined value.
Delete a Client Secret
316 317 318 319 320 321 322 323 324 325 326 327 |
# File 'lib/workos/connect.rb', line 316 def delete_client_secret( id:, request_options: {} ) @client.request( method: :delete, path: "/connect/client_secrets/#{WorkOS::Util.encode_path(id)}", auth: true, request_options: ) nil end |
#get_application(id:, request_options: {}) ⇒ WorkOS::ConnectApplication
Get a Connect Application
209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/workos/connect.rb', line 209 def get_application( id:, request_options: {} ) response = @client.request( method: :get, path: "/connect/applications/#{WorkOS::Util.encode_path(id)}", auth: true, request_options: ) result = WorkOS::ConnectApplication.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#list_application_client_secrets(id:, request_options: {}) ⇒ Array<WorkOS::ApplicationCredentialsListItem>
List Client Secrets for a Connect Application
279 280 281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/workos/connect.rb', line 279 def list_application_client_secrets( id:, request_options: {} ) response = @client.request( method: :get, path: "/connect/applications/#{WorkOS::Util.encode_path(id)}/client_secrets", auth: true, request_options: ) parsed = JSON.parse(response.body) (parsed || []).map { |item| WorkOS::ApplicationCredentialsListItem.new(item) } end |
#list_applications(before: nil, after: nil, limit: nil, order: "desc", organization_id: nil, request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::ConnectApplication>
List Connect Applications
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/workos/connect.rb', line 50 def list_applications( before: nil, after: nil, limit: nil, order: "desc", organization_id: nil, request_options: {} ) params = { "before" => before, "after" => after, "limit" => limit, "order" => order, "organization_id" => organization_id }.compact response = @client.request( method: :get, path: "/connect/applications", auth: true, params: params, request_options: ) fetch_next = ->(cursor) { list_applications( before: before, after: cursor, limit: limit, order: order, organization_id: organization_id, request_options: ) } WorkOS::Types::ListStruct.from_response( response, model: WorkOS::ConnectApplication, filters: {before: before, limit: limit, order: order, organization_id: organization_id}, fetch_next: fetch_next ) end |
#update_application(id:, name: nil, description: nil, scopes: nil, redirect_uris: nil, request_options: {}) ⇒ WorkOS::ConnectApplication
Update a Connect Application
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
# File 'lib/workos/connect.rb', line 232 def update_application( id:, name: nil, description: nil, scopes: nil, redirect_uris: nil, request_options: {} ) body = { "name" => name, "description" => description, "scopes" => scopes, "redirect_uris" => redirect_uris }.compact response = @client.request( method: :put, path: "/connect/applications/#{WorkOS::Util.encode_path(id)}", auth: true, body: body, request_options: ) result = WorkOS::ConnectApplication.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |