Class: X::Space
- Extended by:
- BatchFinders
- Defined in:
- x-objects/lib/x/objects/space.rb
Overview
A live audio space
The space endpoints take only app-only authentication, so a client that signs with OAuth 1.0a reads spaces with a copy that authenticates as the app, while the spaces and posts it reads hold the client, so that they act as the user.
Constant Summary collapse
- FIELDS =
Every public space field
A minor release may add to it the fields the API adds, so that a lookup asks for them too; see Resource#hydrated? for what that means for a resource looked up with a list of fields of its own.
%w[created_at ended_at id is_ticketed lang participant_count scheduled_start started_at state subscriber_count title updated_at].freeze
- EXPANSIONS =
Every expansion available on space endpoints
A minor release may add to it the expansions the API adds, so that a lookup asks for them too; see Resource#hydrated? for what that means for a resource looked up with a list of expansions of its own.
%w[creator_id host_ids invited_user_ids speaker_ids topic_ids].freeze
Instance Attribute Summary collapse
-
#created_at ⇒ Time?
readonly
The time when the space was created.
-
#creator_id ⇒ Integer?
readonly
The identifier of the creator.
-
#ended_at ⇒ Time?
readonly
The time when the space ended.
-
#host_ids ⇒ Array<Integer>
readonly
The identifiers of the hosts.
-
#invited_user_ids ⇒ Array<Integer>
readonly
The identifiers of the invited users.
-
#lang ⇒ String?
readonly
The BCP 47 language tag.
-
#participant_count ⇒ Integer?
readonly
The number of participants.
-
#scheduled_start ⇒ Time?
readonly
The scheduled start time.
-
#speaker_ids ⇒ Array<Integer>
readonly
The identifiers of the speakers.
-
#started_at ⇒ Time?
readonly
The time when the space started.
-
#state ⇒ String?
readonly
The state: live, scheduled, or ended.
-
#subscriber_count ⇒ Integer?
readonly
The number of subscribers.
-
#ticketed ⇒ Boolean?
readonly
Whether the space requires a ticket, the is_ticketed field.
-
#title ⇒ String?
readonly
The title.
-
#topic_ids ⇒ Array<Integer>
readonly
The identifiers of the topics.
-
#updated_at ⇒ Time?
readonly
The time when the space was last updated.
Class Method Summary collapse
-
.default_params ⇒ Hash{String => Array<String>}
The default query parameters requesting every space field and expansion.
-
.find_all_by_creator(users, client:, concurrency: BatchFinders::DEFAULT_CONCURRENCY, **params) {|problem| ... } ⇒ Array<Space>
Look up the live and scheduled spaces many users created, in parallel batches.
-
.search(query, client:, **params) ⇒ Cursor
Search spaces by their titles.
Instance Method Summary collapse
-
#buyers(**params) ⇒ Cursor
The users who bought a ticket to this space.
-
#creator ⇒ User?
The creator, resolved from the includes or as a stub holding only its identifier.
-
#hosts ⇒ Array<User>
The hosts, resolved from the includes or as stubs holding only their identifiers.
-
#invited_users ⇒ Array<User>
The invited users, from the includes or as stubs holding only their identifiers.
-
#posts(**params) ⇒ Cursor
(also: #tweets)
The posts shared in this space.
-
#speakers ⇒ Array<User>
The speakers, from the includes or as stubs holding only their identifiers.
-
#ticketed? ⇒ Boolean
Check whether the space requires a ticket.
-
#topics ⇒ Array<Topic>
The topics, from the includes or as stubs holding only their identifiers.
Constructor Details
This class inherits a constructor from X::Resource
Instance Attribute Details
#created_at ⇒ Time? (readonly)
The time when the space was created
155 |
# File 'x-objects/lib/x/objects/space.rb', line 155 attribute :created_at, :time |
#creator_id ⇒ Integer? (readonly)
The identifier of the creator
226 |
# File 'x-objects/lib/x/objects/space.rb', line 226 attribute :creator_id, :integer |
#ended_at ⇒ Time? (readonly)
The time when the space ended
171 |
# File 'x-objects/lib/x/objects/space.rb', line 171 attribute :ended_at, :time |
#host_ids ⇒ Array<Integer> (readonly)
The identifiers of the hosts
234 |
# File 'x-objects/lib/x/objects/space.rb', line 234 attribute :host_ids, :integers |
#invited_user_ids ⇒ Array<Integer> (readonly)
The identifiers of the invited users
250 |
# File 'x-objects/lib/x/objects/space.rb', line 250 attribute :invited_user_ids, :integers |
#lang ⇒ String? (readonly)
The BCP 47 language tag
147 |
# File 'x-objects/lib/x/objects/space.rb', line 147 attribute :lang |
#participant_count ⇒ Integer? (readonly)
The number of participants
210 |
# File 'x-objects/lib/x/objects/space.rb', line 210 attribute :participant_count, :integer |
#scheduled_start ⇒ Time? (readonly)
The scheduled start time
179 |
# File 'x-objects/lib/x/objects/space.rb', line 179 attribute :scheduled_start, :time |
#speaker_ids ⇒ Array<Integer> (readonly)
The identifiers of the speakers
242 |
# File 'x-objects/lib/x/objects/space.rb', line 242 attribute :speaker_ids, :integers |
#started_at ⇒ Time? (readonly)
The time when the space started
163 |
# File 'x-objects/lib/x/objects/space.rb', line 163 attribute :started_at, :time |
#state ⇒ String? (readonly)
The state: live, scheduled, or ended
139 |
# File 'x-objects/lib/x/objects/space.rb', line 139 attribute :state |
#subscriber_count ⇒ Integer? (readonly)
The number of subscribers
218 |
# File 'x-objects/lib/x/objects/space.rb', line 218 attribute :subscriber_count, :integer |
#ticketed ⇒ Boolean? (readonly)
Whether the space requires a ticket, the is_ticketed field
195 |
# File 'x-objects/lib/x/objects/space.rb', line 195 attribute :ticketed, :boolean, key: %w[is_ticketed] |
#title ⇒ String? (readonly)
The title
131 |
# File 'x-objects/lib/x/objects/space.rb', line 131 attribute :title |
#topic_ids ⇒ Array<Integer> (readonly)
The identifiers of the topics
258 |
# File 'x-objects/lib/x/objects/space.rb', line 258 attribute :topic_ids, :integers |
#updated_at ⇒ Time? (readonly)
The time when the space was last updated
187 |
# File 'x-objects/lib/x/objects/space.rb', line 187 attribute :updated_at, :time |
Class Method Details
.default_params ⇒ Hash{String => Array<String>}
The default query parameters requesting every space field and expansion
83 84 85 |
# File 'x-objects/lib/x/objects/space.rb', line 83 def default_params {"space.fields" => FIELDS, "user.fields" => User::FIELDS, "topic.fields" => Topic::FIELDS, "expansions" => EXPANSIONS} end |
.find_all_by_creator(users, client:, concurrency: BatchFinders::DEFAULT_CONCURRENCY, **params) {|problem| ... } ⇒ Array<Space>
Look up the live and scheduled spaces many users created, in parallel batches
The API returns the spaces of up to 100 users at a time, in one response without pages, so the users are looked up that many at a time.
119 120 121 122 123 |
# File 'x-objects/lib/x/objects/space.rb', line 119 def self.find_all_by_creator(users, client:, concurrency: BatchFinders::DEFAULT_CONCURRENCY, **params, &) ids = users.map { |user| Utils.id_of(user, User) } spaces = lookup_in_batches("spaces/by/creator_ids", :user_ids, ids, client:, concurrency:, **params, &) #: Array[Space] spaces.freeze end |
.search(query, client:, **params) ⇒ Cursor
Search spaces by their titles
The API returns the matching spaces in one response, of up to 100 spaces.
98 99 100 |
# File 'x-objects/lib/x/objects/space.rb', line 98 def search(query, client:, **params) Cursor.__send__(:build, self, "spaces/search", client:, params: {query:, max_results: MAX_RESULTS}.merge(params), app_only: true) end |
Instance Method Details
#buyers(**params) ⇒ Cursor
The users who bought a ticket to this space
The authenticated user must have created the space. The endpoint takes only OAuth 2.0 user context, which the object layer cannot route around, so a client that signs with OAuth 1.0a, or authenticates as the app, is refused.
321 |
# File 'x-objects/lib/x/objects/space.rb', line 321 def buyers(**params) = cursor(User, "spaces/#{id}/buyers", max_results: MAX_RESULTS, **params) |
#creator ⇒ User?
The creator, resolved from the includes or as a stub holding only its identifier
266 |
# File 'x-objects/lib/x/objects/space.rb', line 266 reference :creator, :User, key: %w[creator_id] |
#hosts ⇒ Array<User>
The hosts, resolved from the includes or as stubs holding only their identifiers
274 |
# File 'x-objects/lib/x/objects/space.rb', line 274 references :hosts, :User, key: %w[host_ids] |
#invited_users ⇒ Array<User>
The invited users, from the includes or as stubs holding only their identifiers
290 |
# File 'x-objects/lib/x/objects/space.rb', line 290 references :invited_users, :User, key: %w[invited_user_ids] |
#posts(**params) ⇒ Cursor Also known as: tweets
The posts shared in this space
307 308 309 |
# File 'x-objects/lib/x/objects/space.rb', line 307 def posts(**params) cursor(Post, "spaces/#{id}/tweets", max_results: MAX_RESULTS, app_only: true, **params) end |
#speakers ⇒ Array<User>
The speakers, from the includes or as stubs holding only their identifiers
282 |
# File 'x-objects/lib/x/objects/space.rb', line 282 references :speakers, :User, key: %w[speaker_ids] |
#ticketed? ⇒ Boolean
Check whether the space requires a ticket
|
|
# File 'x-objects/lib/x/objects/space.rb', line 197
|
#topics ⇒ Array<Topic>
The topics, from the includes or as stubs holding only their identifiers
298 |
# File 'x-objects/lib/x/objects/space.rb', line 298 references :topics, :Topic, key: %w[topic_ids] |