Class: WorkOS::Organizations
- Inherits:
-
Object
- Object
- WorkOS::Organizations
- Defined in:
- lib/workos/organizations.rb
Instance Method Summary collapse
-
#create_organization(name:, allow_profiles_outside_organization: nil, domains: nil, domain_data: nil, metadata: nil, external_id: nil, request_options: {}) ⇒ WorkOS::Organization
Create an Organization.
-
#delete_organization(id:, request_options: {}) ⇒ void
Delete an Organization.
-
#get_audit_log_configuration(id:, request_options: {}) ⇒ WorkOS::AuditLogConfiguration
Get Audit Log Configuration.
-
#get_organization(id:, request_options: {}) ⇒ WorkOS::Organization
Get an Organization.
-
#get_organization_by_external_id(external_id:, request_options: {}) ⇒ WorkOS::Organization
Get an Organization by External ID.
-
#initialize(client) ⇒ Organizations
constructor
A new instance of Organizations.
-
#list_organizations(before: nil, after: nil, limit: nil, order: "desc", domains: nil, search: nil, request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::Organization>
List Organizations.
-
#update_organization(id:, name: nil, allow_profiles_outside_organization: nil, domains: nil, domain_data: nil, stripe_customer_id: nil, metadata: nil, external_id: nil, request_options: {}) ⇒ WorkOS::Organization
Update an Organization.
Constructor Details
#initialize(client) ⇒ Organizations
Returns a new instance of Organizations.
9 10 11 |
# File 'lib/workos/organizations.rb', line 9 def initialize(client) @client = client end |
Instance Method Details
#create_organization(name:, allow_profiles_outside_organization: nil, domains: nil, domain_data: nil, metadata: nil, external_id: nil, request_options: {}) ⇒ WorkOS::Organization
Create an Organization
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/workos/organizations.rb', line 74 def create_organization( name:, allow_profiles_outside_organization: nil, domains: nil, domain_data: nil, metadata: nil, external_id: nil, request_options: {} ) body = { "name" => name, "allow_profiles_outside_organization" => allow_profiles_outside_organization, "domains" => domains, "domain_data" => domain_data, "metadata" => , "external_id" => external_id }.compact response = @client.request( method: :post, path: "/organizations", auth: true, body: body, request_options: ) result = WorkOS::Organization.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 |
#delete_organization(id:, request_options: {}) ⇒ void
This method returns an undefined value.
Delete an Organization
188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/workos/organizations.rb', line 188 def delete_organization( id:, request_options: {} ) @client.request( method: :delete, path: "/organizations/#{WorkOS::Util.encode_path(id)}", auth: true, request_options: ) nil end |
#get_audit_log_configuration(id:, request_options: {}) ⇒ WorkOS::AuditLogConfiguration
Get Audit Log Configuration
205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/workos/organizations.rb', line 205 def get_audit_log_configuration( id:, request_options: {} ) response = @client.request( method: :get, path: "/organizations/#{WorkOS::Util.encode_path(id)}/audit_log_configuration", auth: true, request_options: ) result = WorkOS::AuditLogConfiguration.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 |
#get_organization(id:, request_options: {}) ⇒ WorkOS::Organization
Get an Organization
126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/workos/organizations.rb', line 126 def get_organization( id:, request_options: {} ) response = @client.request( method: :get, path: "/organizations/#{WorkOS::Util.encode_path(id)}", auth: true, request_options: ) result = WorkOS::Organization.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 |
#get_organization_by_external_id(external_id:, request_options: {}) ⇒ WorkOS::Organization
Get an Organization by External ID
107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/workos/organizations.rb', line 107 def get_organization_by_external_id( external_id:, request_options: {} ) response = @client.request( method: :get, path: "/organizations/external_id/#{WorkOS::Util.encode_path(external_id)}", auth: true, request_options: ) result = WorkOS::Organization.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_organizations(before: nil, after: nil, limit: nil, order: "desc", domains: nil, search: nil, request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::Organization>
List Organizations
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/workos/organizations.rb', line 22 def list_organizations( before: nil, after: nil, limit: nil, order: "desc", domains: nil, search: nil, request_options: {} ) params = { "before" => before, "after" => after, "limit" => limit, "order" => order, "domains" => domains, "search" => search }.compact response = @client.request( method: :get, path: "/organizations", auth: true, params: params, request_options: ) fetch_next = ->(cursor) { list_organizations( before: before, after: cursor, limit: limit, order: order, domains: domains, search: search, request_options: ) } WorkOS::Types::ListStruct.from_response( response, model: WorkOS::Organization, filters: {before: before, limit: limit, order: order, domains: domains, search: search}, fetch_next: fetch_next ) end |
#update_organization(id:, name: nil, allow_profiles_outside_organization: nil, domains: nil, domain_data: nil, stripe_customer_id: nil, metadata: nil, external_id: nil, request_options: {}) ⇒ WorkOS::Organization
Update an Organization
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/workos/organizations.rb', line 152 def update_organization( id:, name: nil, allow_profiles_outside_organization: nil, domains: nil, domain_data: nil, stripe_customer_id: nil, metadata: nil, external_id: nil, request_options: {} ) body = { "name" => name, "allow_profiles_outside_organization" => allow_profiles_outside_organization, "domains" => domains, "domain_data" => domain_data, "stripe_customer_id" => stripe_customer_id, "metadata" => , "external_id" => external_id }.compact response = @client.request( method: :put, path: "/organizations/#{WorkOS::Util.encode_path(id)}", auth: true, body: body, request_options: ) result = WorkOS::Organization.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 |