Class: WorkOS::Widgets
- Inherits:
-
Object
- Object
- WorkOS::Widgets
- Defined in:
- lib/workos/widgets.rb
Instance Method Summary collapse
-
#create_token(organization_id:, user_id: nil, scopes: nil, request_options: {}) ⇒ WorkOS::WidgetSessionTokenResponse
Generate a widget token.
-
#initialize(client) ⇒ Widgets
constructor
A new instance of Widgets.
Constructor Details
#initialize(client) ⇒ Widgets
Returns a new instance of Widgets.
9 10 11 |
# File 'lib/workos/widgets.rb', line 9 def initialize(client) @client = client end |
Instance Method Details
#create_token(organization_id:, user_id: nil, scopes: nil, request_options: {}) ⇒ WorkOS::WidgetSessionTokenResponse
Generate a widget token
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/widgets.rb', line 19 def create_token( organization_id:, user_id: nil, scopes: nil, request_options: {} ) body = { "organization_id" => organization_id, "user_id" => user_id, "scopes" => scopes }.compact response = @client.request( method: :post, path: "/widgets/token", auth: true, body: body, request_options: ) result = WorkOS::WidgetSessionTokenResponse.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 |