audience-kit 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +8 -0
- data/CHANGELOG.md +21 -0
- data/README.md +163 -22
- data/docs/reference.md +219 -0
- data/docs/sign-in.md +197 -0
- data/docs/websites.md +167 -0
- data/lib/audience-kit/color.rb +68 -0
- data/lib/audience-kit/configuration.rb +54 -0
- data/lib/audience-kit/coordinate.rb +76 -0
- data/lib/audience-kit/cover_pass.rb +57 -0
- data/lib/audience-kit/credential.rb +140 -0
- data/lib/audience-kit/credential_store.rb +86 -0
- data/lib/audience-kit/device_description.rb +29 -0
- data/lib/audience-kit/environment.rb +34 -0
- data/lib/audience-kit/error.rb +190 -0
- data/lib/audience-kit/model.rb +136 -0
- data/lib/audience-kit/models.rb +942 -0
- data/lib/audience-kit/operations.rb +501 -0
- data/lib/audience-kit/queries.rb +632 -0
- data/lib/audience-kit/report_target.rb +34 -0
- data/lib/audience-kit/schema_shape.rb +31 -0
- data/lib/audience-kit/session.rb +580 -0
- data/lib/audience-kit/version.rb +6 -1
- data/lib/audience-kit.rb +119 -23
- data/sig/audience/kit.rbs +651 -14
- metadata +23 -5
- data/lib/audience-kit/event.rb +0 -18
- data/lib/audience-kit/venue.rb +0 -18
|
@@ -0,0 +1,942 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Audience
|
|
4
|
+
module Kit
|
|
5
|
+
# A Facebook Page: a venue's or person's (Listings and Facebook).
|
|
6
|
+
class Page < Model
|
|
7
|
+
# @!method id
|
|
8
|
+
# @return [String]
|
|
9
|
+
attribute :id, default: ""
|
|
10
|
+
# @!method name
|
|
11
|
+
# @return [String]
|
|
12
|
+
attribute :name, default: ""
|
|
13
|
+
# @!method photo_url
|
|
14
|
+
# @return [String, nil]
|
|
15
|
+
attribute :photo_url
|
|
16
|
+
# @!method banner_url
|
|
17
|
+
# @return [String, nil]
|
|
18
|
+
attribute :banner_url
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# A person as a list shows them: a host, an act, an attendee, a chat member.
|
|
22
|
+
class Profile < Model
|
|
23
|
+
# @!method id
|
|
24
|
+
# @return [String]
|
|
25
|
+
attribute :id, default: ""
|
|
26
|
+
# @!method name
|
|
27
|
+
# @return [String]
|
|
28
|
+
attribute :name, default: ""
|
|
29
|
+
# @!method avatar_url
|
|
30
|
+
# @return [String, nil]
|
|
31
|
+
attribute :avatar_url
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# The audience itself: its name, subdomain and theme.
|
|
35
|
+
class Audience < Model
|
|
36
|
+
# @!method id
|
|
37
|
+
# @return [String]
|
|
38
|
+
attribute :id, default: ""
|
|
39
|
+
# @!method name
|
|
40
|
+
# @return [String]
|
|
41
|
+
attribute :name, default: ""
|
|
42
|
+
# @!method subdomain
|
|
43
|
+
# @return [String, nil]
|
|
44
|
+
attribute :subdomain
|
|
45
|
+
# @!method theme
|
|
46
|
+
# @return [Hash, nil] +preset+, +tagline+, and +light+ and +dark+ lists of +{ name, value }+ tokens
|
|
47
|
+
attribute :theme, :hash
|
|
48
|
+
|
|
49
|
+
# A theme token's color, preferring its dark override in dark mode.
|
|
50
|
+
# @param token [String]
|
|
51
|
+
# @param dark [Boolean]
|
|
52
|
+
# @return [Color, nil]
|
|
53
|
+
def color(token, dark: false) = Color.from_theme(theme, token, dark: dark)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# The signed-in person's own profile (+me { self }+).
|
|
57
|
+
class SelfUser < Model
|
|
58
|
+
# @!method id
|
|
59
|
+
# @return [String]
|
|
60
|
+
attribute :id, default: ""
|
|
61
|
+
# @!method name
|
|
62
|
+
# @return [String]
|
|
63
|
+
attribute :name, default: ""
|
|
64
|
+
# @!method first_name
|
|
65
|
+
# @return [String, nil]
|
|
66
|
+
attribute :first_name
|
|
67
|
+
# @!method last_name
|
|
68
|
+
# @return [String, nil]
|
|
69
|
+
attribute :last_name
|
|
70
|
+
# @!method email_address
|
|
71
|
+
# @return [String, nil]
|
|
72
|
+
attribute :email_address
|
|
73
|
+
# @!method admin?
|
|
74
|
+
# @return [Boolean]
|
|
75
|
+
attribute :admin?, :boolean, path: "isAdmin", default: false
|
|
76
|
+
# @!method presence
|
|
77
|
+
# @return [String, nil]
|
|
78
|
+
attribute :presence
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# A tag on a venue, person or event, or a tribe people identify with.
|
|
82
|
+
class Tag < Model
|
|
83
|
+
# @!method id
|
|
84
|
+
# @return [String]
|
|
85
|
+
attribute :id, default: ""
|
|
86
|
+
# @!method name
|
|
87
|
+
# @return [String]
|
|
88
|
+
attribute :name, default: ""
|
|
89
|
+
# @!method color_hex
|
|
90
|
+
# @return [String, nil] its chip color, e.g. +"#ff2d55"+
|
|
91
|
+
attribute :color_hex, path: "color"
|
|
92
|
+
# @!method tribe?
|
|
93
|
+
# @return [Boolean] whether people can identify with it
|
|
94
|
+
attribute :tribe?, :boolean, path: "tribe", default: false
|
|
95
|
+
|
|
96
|
+
# @return [Color, nil]
|
|
97
|
+
def color = color_hex && Color.from_hex(color_hex)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# One of the signed-in person's tribes.
|
|
101
|
+
class TribeIdentification < Model
|
|
102
|
+
# @!method private?
|
|
103
|
+
# @return [Boolean] whether only they see it
|
|
104
|
+
attribute :private?, :boolean, path: "isPrivate", default: true
|
|
105
|
+
# @!method tag
|
|
106
|
+
# @return [Tag, nil]
|
|
107
|
+
attribute :tag, "Tag"
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# A locale: a city or area the audience lists.
|
|
111
|
+
class Locale < Model
|
|
112
|
+
# @!method id
|
|
113
|
+
# @return [String]
|
|
114
|
+
attribute :id, default: ""
|
|
115
|
+
# @!method name
|
|
116
|
+
# @return [String]
|
|
117
|
+
attribute :name, default: ""
|
|
118
|
+
# @!method label
|
|
119
|
+
# @return [String, nil]
|
|
120
|
+
attribute :label
|
|
121
|
+
# @!method city_names
|
|
122
|
+
# @return [Array<String>]
|
|
123
|
+
attribute :city_names, :strings
|
|
124
|
+
# @!method banner_url
|
|
125
|
+
# @return [String, nil]
|
|
126
|
+
attribute :banner_url
|
|
127
|
+
# @!method place_id
|
|
128
|
+
# @return [String, nil] its Google place ID (Listings and Google Places)
|
|
129
|
+
attribute :place_id, path: %w[profile places placeId]
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# Where a venue is.
|
|
133
|
+
class Location < Model
|
|
134
|
+
# @!method id
|
|
135
|
+
# @return [String, nil]
|
|
136
|
+
attribute :id
|
|
137
|
+
# @!method address
|
|
138
|
+
# @return [String, nil]
|
|
139
|
+
attribute :address
|
|
140
|
+
# @!method place_id
|
|
141
|
+
# @return [String, nil] its Google place ID (Google Places)
|
|
142
|
+
attribute :place_id, path: %w[places placeId]
|
|
143
|
+
|
|
144
|
+
# Where it is on the map, from its WKT point.
|
|
145
|
+
# @return [Coordinate, nil]
|
|
146
|
+
def coordinate = self["point"].is_a?(String) ? Coordinate.from_wkt(self["point"]) : nil
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# An amount of money in a currency's minor unit.
|
|
150
|
+
class Money < Model
|
|
151
|
+
# The symbols {#format} writes before amounts in the currencies AudienceKit audiences use.
|
|
152
|
+
SYMBOLS = { "usd" => "$", "cad" => "CA$", "aud" => "A$", "gbp" => "£", "eur" => "€", "mxn" => "MX$" }.freeze
|
|
153
|
+
|
|
154
|
+
# @!method cents
|
|
155
|
+
# @return [Integer]
|
|
156
|
+
attribute :cents, :integer, default: 0
|
|
157
|
+
|
|
158
|
+
# @return [String] the ISO currency code, lowercase
|
|
159
|
+
def currency = (self["currency"].is_a?(String) ? self["currency"] : "usd").downcase
|
|
160
|
+
|
|
161
|
+
# @return [Float] the amount in the major unit
|
|
162
|
+
def amount = cents / 100.0
|
|
163
|
+
|
|
164
|
+
# The amount for people, e.g. "$12.00" or "12.00 CHF".
|
|
165
|
+
# @return [String]
|
|
166
|
+
def format
|
|
167
|
+
whole, fraction = Kernel.format("%.2f", amount.abs).split(".")
|
|
168
|
+
sign = "-" if cents.negative?
|
|
169
|
+
number = "#{whole.reverse.scan(/\d{1,3}/).join(",").reverse}.#{fraction}"
|
|
170
|
+
SYMBOLS.key?(currency) ? "#{sign}#{SYMBOLS[currency]}#{number}" : "#{sign}#{number} #{currency.upcase}"
|
|
171
|
+
end
|
|
172
|
+
alias to_s format
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
# A ticket seller's offer to get into an event or venue.
|
|
176
|
+
class AdmissionOffer < Model
|
|
177
|
+
# @!method price
|
|
178
|
+
# @return [Money, nil]
|
|
179
|
+
attribute :price, "Money"
|
|
180
|
+
# @!method url
|
|
181
|
+
# @return [String, nil] where to buy it
|
|
182
|
+
attribute :url
|
|
183
|
+
# @!method seller_key
|
|
184
|
+
# @return [String, nil]
|
|
185
|
+
attribute :seller_key, path: %w[seller key]
|
|
186
|
+
# @!method seller_name
|
|
187
|
+
# @return [String, nil]
|
|
188
|
+
attribute :seller_name, path: %w[seller name]
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
# A message in a venue's or locale's chat.
|
|
192
|
+
class ChatMessage < Model
|
|
193
|
+
# @!method id
|
|
194
|
+
# @return [String]
|
|
195
|
+
attribute :id, default: ""
|
|
196
|
+
# @!method name
|
|
197
|
+
# @return [String, nil] who sent it
|
|
198
|
+
attribute :name
|
|
199
|
+
# @!method user_id
|
|
200
|
+
# @return [String, nil]
|
|
201
|
+
attribute :user_id
|
|
202
|
+
# @!method avatar_url
|
|
203
|
+
# @return [String, nil]
|
|
204
|
+
attribute :avatar_url
|
|
205
|
+
# @!method photo_url
|
|
206
|
+
# @return [String, nil]
|
|
207
|
+
attribute :photo_url
|
|
208
|
+
# @!method sent_at
|
|
209
|
+
# @return [Time, nil]
|
|
210
|
+
attribute :sent_at, :time
|
|
211
|
+
# @!method role
|
|
212
|
+
# @return [String, nil]
|
|
213
|
+
attribute :role
|
|
214
|
+
# @!method kind
|
|
215
|
+
# @return [String, nil]
|
|
216
|
+
attribute :kind
|
|
217
|
+
# @!method title
|
|
218
|
+
# @return [String, nil]
|
|
219
|
+
attribute :title
|
|
220
|
+
# @!method pinned?
|
|
221
|
+
# @return [Boolean]
|
|
222
|
+
attribute :pinned?, :boolean, path: "pinned", default: false
|
|
223
|
+
|
|
224
|
+
# @return [String, nil] the text
|
|
225
|
+
def body = Model.cast(self["body"], :string, nil) || Model.cast(self["message"], :string, nil)
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
# A venue: a bar, club or space. In a list it carries its locale, location, tags and Facebook Page; on its page
|
|
229
|
+
# ({Operations#venue_detail}) also its description, profile, chat and upcoming events, as far as the audience's
|
|
230
|
+
# modules go.
|
|
231
|
+
class Venue < Model
|
|
232
|
+
# @!method id
|
|
233
|
+
# @return [String]
|
|
234
|
+
attribute :id, default: ""
|
|
235
|
+
# @!method name
|
|
236
|
+
# @return [String]
|
|
237
|
+
attribute :name, default: ""
|
|
238
|
+
# @!method hidden?
|
|
239
|
+
# @return [Boolean]
|
|
240
|
+
attribute :hidden?, :boolean, path: "hidden", default: false
|
|
241
|
+
# @!method order
|
|
242
|
+
# @return [Integer, nil]
|
|
243
|
+
attribute :order, :integer
|
|
244
|
+
# @!method photo_url
|
|
245
|
+
# @return [String, nil]
|
|
246
|
+
attribute :photo_url
|
|
247
|
+
# @!method banner_url
|
|
248
|
+
# @return [String, nil]
|
|
249
|
+
attribute :banner_url
|
|
250
|
+
# @!method locale
|
|
251
|
+
# @return [Locale, nil]
|
|
252
|
+
attribute :locale, "Locale"
|
|
253
|
+
# @!method location
|
|
254
|
+
# @return [Location, nil]
|
|
255
|
+
attribute :location, "Location"
|
|
256
|
+
# @!method tags
|
|
257
|
+
# @return [Array<Tag>]
|
|
258
|
+
attribute :tags, ["Tag"]
|
|
259
|
+
# @!method facebook_page
|
|
260
|
+
# @return [Page, nil] its Facebook Page (Listings and Facebook)
|
|
261
|
+
attribute :facebook_page, "Page", path: %w[profile facebook page]
|
|
262
|
+
# @!method description
|
|
263
|
+
# @return [String, nil] on its page: what it says about itself
|
|
264
|
+
attribute :description
|
|
265
|
+
# @!method address
|
|
266
|
+
# @return [String, nil] on its page: its street address
|
|
267
|
+
attribute :address, path: %w[profile address]
|
|
268
|
+
# @!method phone
|
|
269
|
+
# @return [String, nil] on its page
|
|
270
|
+
attribute :phone, path: %w[profile phone]
|
|
271
|
+
# @!method website
|
|
272
|
+
# @return [String, nil] on its page
|
|
273
|
+
attribute :website, path: %w[profile website]
|
|
274
|
+
# @!method social_links
|
|
275
|
+
# @return [Array<Hash>] on its page: its links elsewhere, each +id handle provider url+
|
|
276
|
+
attribute :social_links, :hashes, path: %w[profile socialLinks]
|
|
277
|
+
# @!method recent_messages
|
|
278
|
+
# @return [Array<ChatMessage>] on its page: its chat's latest messages, oldest first
|
|
279
|
+
attribute :recent_messages, ["ChatMessage"], path: %w[chat recentMessages]
|
|
280
|
+
# @!method upcoming_events
|
|
281
|
+
# @return [Array<Event>] on its page: what's coming up there
|
|
282
|
+
attribute :upcoming_events, ["Event"], path: %w[events upcoming]
|
|
283
|
+
|
|
284
|
+
# On its page: whether its chat is open (Chat); nil when the audience has no chat.
|
|
285
|
+
# @return [Boolean, nil]
|
|
286
|
+
def chat_open = self["chat"].is_a?(Hash) ? self["chat"]["open"] == true : nil
|
|
287
|
+
|
|
288
|
+
# Where it is on the map, when its location has a point.
|
|
289
|
+
# @return [Coordinate, nil]
|
|
290
|
+
def coordinate = location&.coordinate
|
|
291
|
+
|
|
292
|
+
# Reads a venue's page with the module-level session ({Kit.session}).
|
|
293
|
+
# @param id [String]
|
|
294
|
+
# @return [Venue]
|
|
295
|
+
# @raise [Error] {Error::NOT_FOUND} when there is no such venue
|
|
296
|
+
def self.find(id)
|
|
297
|
+
Kit.session.venue_detail(id.to_s) || raise(Error.not_found("There is no venue #{id}."))
|
|
298
|
+
end
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
# A person the audience lists: a promoter, DJ, drag artist or act.
|
|
302
|
+
class Person < Model
|
|
303
|
+
# @!method id
|
|
304
|
+
# @return [String]
|
|
305
|
+
attribute :id, default: ""
|
|
306
|
+
# @!method name
|
|
307
|
+
# @return [String]
|
|
308
|
+
attribute :name, default: ""
|
|
309
|
+
# @!method avatar_url
|
|
310
|
+
# @return [String, nil]
|
|
311
|
+
attribute :avatar_url
|
|
312
|
+
# @!method banner_url
|
|
313
|
+
# @return [String, nil]
|
|
314
|
+
attribute :banner_url
|
|
315
|
+
# @!method order
|
|
316
|
+
# @return [Integer, nil]
|
|
317
|
+
attribute :order, :integer
|
|
318
|
+
# @!method global?
|
|
319
|
+
# @return [Boolean] whether they are listed in every locale
|
|
320
|
+
attribute :global?, :boolean, path: "global", default: false
|
|
321
|
+
# @!method like_required?
|
|
322
|
+
# @return [Boolean]
|
|
323
|
+
attribute :like_required?, :boolean, path: "likeRequired", default: false
|
|
324
|
+
# @!method tags
|
|
325
|
+
# @return [Array<Tag>]
|
|
326
|
+
attribute :tags, ["Tag"]
|
|
327
|
+
# @!method locales
|
|
328
|
+
# @return [Array<Locale>]
|
|
329
|
+
attribute :locales, ["Locale"]
|
|
330
|
+
# @!method facebook_page
|
|
331
|
+
# @return [Page, nil]
|
|
332
|
+
attribute :facebook_page, "Page", path: %w[profile facebook page]
|
|
333
|
+
# @!method home_venue
|
|
334
|
+
# @return [Venue, nil] where they're usually found
|
|
335
|
+
attribute :home_venue, "Venue", path: %w[venues home]
|
|
336
|
+
# @!method involvements
|
|
337
|
+
# @return [Array<Hash>] their events, each +relationship role via node+
|
|
338
|
+
attribute :involvements, :hashes, path: %w[events involvements edges]
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
# A cover charge on a night: the amount, the fee and the total the buyer pays, whether it can be paid in the app,
|
|
342
|
+
# its coat check, and on a sliding scale the range the buyer picks from.
|
|
343
|
+
class CoverCharge < Model
|
|
344
|
+
# @!method amount
|
|
345
|
+
# @return [Money, nil]
|
|
346
|
+
attribute :amount, "Money"
|
|
347
|
+
# @!method fee
|
|
348
|
+
# @return [Money, nil]
|
|
349
|
+
attribute :fee, "Money"
|
|
350
|
+
# @!method total
|
|
351
|
+
# @return [Money, nil]
|
|
352
|
+
attribute :total, "Money"
|
|
353
|
+
# @!method night
|
|
354
|
+
# @return [String, nil] +YYYY-MM-DD+
|
|
355
|
+
attribute :night
|
|
356
|
+
# @!method from
|
|
357
|
+
# @return [Time, nil] when it starts being charged
|
|
358
|
+
attribute :from, :time
|
|
359
|
+
# @!method payable?
|
|
360
|
+
# @return [Boolean] whether it can be paid in the app
|
|
361
|
+
attribute :payable?, :boolean, path: "payable", default: false
|
|
362
|
+
# @!method event
|
|
363
|
+
# @return [Hash, nil] +id name+
|
|
364
|
+
attribute :event, :hash
|
|
365
|
+
# @!method coat_check
|
|
366
|
+
# @return [Hash, nil] +amount fee total night payable+
|
|
367
|
+
attribute :coat_check, :hash
|
|
368
|
+
# @!method scale_min
|
|
369
|
+
# @return [Money, nil]
|
|
370
|
+
attribute :scale_min, "Money", path: %w[scale min]
|
|
371
|
+
# @!method scale_max
|
|
372
|
+
# @return [Money, nil]
|
|
373
|
+
attribute :scale_max, "Money", path: %w[scale max]
|
|
374
|
+
# @!method scale_suggested
|
|
375
|
+
# @return [Money, nil]
|
|
376
|
+
attribute :scale_suggested, "Money", path: %w[scale suggested]
|
|
377
|
+
|
|
378
|
+
# Whether the buyer picks what to pay.
|
|
379
|
+
# @return [Boolean]
|
|
380
|
+
def sliding_scale? = !scale_min.nil? && !scale_max.nil?
|
|
381
|
+
|
|
382
|
+
# Whether the venue checks coats that night and takes payment for it in the app.
|
|
383
|
+
# @return [Boolean]
|
|
384
|
+
def coat_check? = coat_check&.dig("payable") == true
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
# An event: its own fields, then those of the Venues, RSVP, People and Ticketing modules the audience has. A
|
|
388
|
+
# module the audience doesn't have leaves its readers nil or empty.
|
|
389
|
+
class Event < Model
|
|
390
|
+
# @!method id
|
|
391
|
+
# @return [String]
|
|
392
|
+
attribute :id, default: ""
|
|
393
|
+
# @!method name
|
|
394
|
+
# @return [String]
|
|
395
|
+
attribute :name, default: ""
|
|
396
|
+
# @!method description
|
|
397
|
+
# @return [String, nil]
|
|
398
|
+
attribute :description
|
|
399
|
+
# @!method start_at
|
|
400
|
+
# @return [Time, nil]
|
|
401
|
+
attribute :start_at, :time
|
|
402
|
+
# @!method end_at
|
|
403
|
+
# @return [Time, nil]
|
|
404
|
+
attribute :end_at, :time
|
|
405
|
+
# @!method featured?
|
|
406
|
+
# @return [Boolean]
|
|
407
|
+
attribute :featured?, :boolean, path: "isFeatured", default: false
|
|
408
|
+
# @!method canceled?
|
|
409
|
+
# @return [Boolean]
|
|
410
|
+
attribute :canceled?, :boolean, path: "isCanceled", default: false
|
|
411
|
+
# @!method banner_url
|
|
412
|
+
# @return [String, nil]
|
|
413
|
+
attribute :banner_url
|
|
414
|
+
# @!method source_url
|
|
415
|
+
# @return [String, nil] where it came from, e.g. its Facebook event
|
|
416
|
+
attribute :source_url
|
|
417
|
+
# @!method locale
|
|
418
|
+
# @return [Locale, nil]
|
|
419
|
+
attribute :locale, "Locale"
|
|
420
|
+
# @!method tags
|
|
421
|
+
# @return [Array<Tag>]
|
|
422
|
+
attribute :tags, ["Tag"]
|
|
423
|
+
# @!method venue_name
|
|
424
|
+
# @return [String, nil] the venue's name as the event gives it, even where the venue isn't listed (Venues)
|
|
425
|
+
attribute :venue_name, path: %w[venue name]
|
|
426
|
+
# @!method venue
|
|
427
|
+
# @return [Venue, nil] the listed venue it's at (Venues)
|
|
428
|
+
attribute :venue, "Venue", path: %w[venue venue]
|
|
429
|
+
# @!method rsvp
|
|
430
|
+
# @return [String, nil] the signed-in person's answer: ATTENDING, MAYBE, DECLINED or UNSURE (RSVP)
|
|
431
|
+
attribute :rsvp, path: %w[rsvp mine]
|
|
432
|
+
# @!method rsvp_count
|
|
433
|
+
# @return [Integer, nil] how many are going (RSVP)
|
|
434
|
+
attribute :rsvp_count, :integer, path: %w[rsvp count]
|
|
435
|
+
# @!method hosts
|
|
436
|
+
# @return [Array<Profile>] (People)
|
|
437
|
+
attribute :hosts, ["Profile"], path: %w[people hosts]
|
|
438
|
+
# @!method lineup
|
|
439
|
+
# @return [Array<Profile>] (People)
|
|
440
|
+
attribute :lineup, ["Profile"], path: %w[people lineup]
|
|
441
|
+
# @!method jockeys
|
|
442
|
+
# @return [Array<Profile>] its KJ, DJ or VJ (People)
|
|
443
|
+
attribute :jockeys, ["Profile"], path: %w[people jockeys]
|
|
444
|
+
# @!method jockey_label
|
|
445
|
+
# @return [String, nil] what to call them, e.g. "KJ"
|
|
446
|
+
attribute :jockey_label, path: %w[people jockeyLabel]
|
|
447
|
+
# @!method ticket_url
|
|
448
|
+
# @return [String, nil] where tickets are sold (Ticketing)
|
|
449
|
+
attribute :ticket_url, path: %w[tickets url]
|
|
450
|
+
# @!method offers
|
|
451
|
+
# @return [Array<AdmissionOffer>] (Ticketing)
|
|
452
|
+
attribute :offers, ["AdmissionOffer"], path: %w[tickets offers]
|
|
453
|
+
# @!method cover
|
|
454
|
+
# @return [CoverCharge, nil] tonight's cover charge (Ticketing and Cover)
|
|
455
|
+
attribute :cover, "CoverCharge", path: %w[tickets cover charge]
|
|
456
|
+
|
|
457
|
+
# Who runs the night: its hosts, or, when nobody else is linked to it, its KJ, DJ or VJ (a jockey who is the
|
|
458
|
+
# only person on an event is its host everywhere).
|
|
459
|
+
# @return [Array<Profile>]
|
|
460
|
+
def effective_hosts = hosts.empty? && lineup.empty? ? jockeys : hosts
|
|
461
|
+
|
|
462
|
+
# Whether it has ended at +at+ (now by default); an event with no end has ended once it started.
|
|
463
|
+
# @param at [Time]
|
|
464
|
+
# @return [Boolean]
|
|
465
|
+
def ended?(at = Time.now)
|
|
466
|
+
finish = end_at || start_at
|
|
467
|
+
!finish.nil? && finish <= at
|
|
468
|
+
end
|
|
469
|
+
|
|
470
|
+
# Reads an event with the module-level session ({Kit.session}).
|
|
471
|
+
# @param id [String]
|
|
472
|
+
# @return [Event]
|
|
473
|
+
# @raise [Error] {Error::NOT_FOUND} when there is no such event
|
|
474
|
+
def self.find(id)
|
|
475
|
+
Kit.session.event(id.to_s) || raise(Error.not_found("There is no event #{id}."))
|
|
476
|
+
end
|
|
477
|
+
end
|
|
478
|
+
|
|
479
|
+
# A recurring event series, e.g. "Karaoke every Tuesday".
|
|
480
|
+
class EventSeries < Model
|
|
481
|
+
# @!method id
|
|
482
|
+
# @return [String]
|
|
483
|
+
attribute :id, default: ""
|
|
484
|
+
# @!method name
|
|
485
|
+
# @return [String]
|
|
486
|
+
attribute :name, default: ""
|
|
487
|
+
# @!method description
|
|
488
|
+
# @return [String, nil]
|
|
489
|
+
attribute :description
|
|
490
|
+
# @!method recurrence_text
|
|
491
|
+
# @return [String, nil] e.g. "Every Tuesday"
|
|
492
|
+
attribute :recurrence_text
|
|
493
|
+
# @!method starts_on
|
|
494
|
+
# @return [String, nil] +YYYY-MM-DD+
|
|
495
|
+
attribute :starts_on
|
|
496
|
+
# @!method start_time
|
|
497
|
+
# @return [String, nil] +HH:MM+, in {#time_zone}
|
|
498
|
+
attribute :start_time
|
|
499
|
+
# @!method time_zone
|
|
500
|
+
# @return [String, nil] an IANA zone, e.g. America/Phoenix
|
|
501
|
+
attribute :time_zone
|
|
502
|
+
# @!method duration_minutes
|
|
503
|
+
# @return [Integer, nil]
|
|
504
|
+
attribute :duration_minutes, :integer
|
|
505
|
+
# @!method banner_url
|
|
506
|
+
# @return [String, nil]
|
|
507
|
+
attribute :banner_url
|
|
508
|
+
# @!method locale
|
|
509
|
+
# @return [Locale, nil]
|
|
510
|
+
attribute :locale, "Locale"
|
|
511
|
+
# @!method tags
|
|
512
|
+
# @return [Array<Tag>]
|
|
513
|
+
attribute :tags, ["Tag"]
|
|
514
|
+
# @!method venue_name
|
|
515
|
+
# @return [String, nil]
|
|
516
|
+
attribute :venue_name, path: %w[venue name]
|
|
517
|
+
# @!method venue
|
|
518
|
+
# @return [Venue, nil]
|
|
519
|
+
attribute :venue, "Venue", path: %w[venue venue]
|
|
520
|
+
end
|
|
521
|
+
|
|
522
|
+
# An event's RSVPs: how many are going, the signed-in person's own answer and, where asked for, who's going.
|
|
523
|
+
class EventRSVP < Model
|
|
524
|
+
# @!method count
|
|
525
|
+
# @return [Integer] how many are going
|
|
526
|
+
attribute :count, :integer, default: 0
|
|
527
|
+
# @!method mine
|
|
528
|
+
# @return [String, nil] the signed-in person's answer; nil when they haven't answered
|
|
529
|
+
attribute :mine
|
|
530
|
+
# @!method mine_source
|
|
531
|
+
# @return [String, nil] why they count as going: RSVP, or TICKET when they hold one
|
|
532
|
+
attribute :mine_source
|
|
533
|
+
# @!method going
|
|
534
|
+
# @return [Integer, nil] staff only
|
|
535
|
+
attribute :going, :integer, path: %w[counts going]
|
|
536
|
+
# @!method interested
|
|
537
|
+
# @return [Integer, nil] staff only
|
|
538
|
+
attribute :interested, :integer, path: %w[counts interested]
|
|
539
|
+
# @!method tickets
|
|
540
|
+
# @return [Integer, nil] staff only
|
|
541
|
+
attribute :tickets, :integer, path: %w[counts tickets]
|
|
542
|
+
# @!method attendees
|
|
543
|
+
# @return [Array<Hash>] the first attendees, each +profile friend source+
|
|
544
|
+
attribute :attendees, :hashes
|
|
545
|
+
|
|
546
|
+
# @return [Boolean] whether the signed-in person is going
|
|
547
|
+
def going? = mine == "ATTENDING"
|
|
548
|
+
|
|
549
|
+
# @return [Array<Profile>] the attendees' profiles
|
|
550
|
+
def attendee_profiles = Profile.list(attendees.map { |attendee| attendee["profile"] })
|
|
551
|
+
end
|
|
552
|
+
|
|
553
|
+
# A cover pass or coat check ticket the signed-in person bought, with the secret its door code is made from
|
|
554
|
+
# ({#pass_code}).
|
|
555
|
+
class Admission < Model
|
|
556
|
+
# @!method id
|
|
557
|
+
# @return [String]
|
|
558
|
+
attribute :id, default: ""
|
|
559
|
+
# @!method status
|
|
560
|
+
# @return [String] PENDING, PAID, FAILED, CANCELED, REFUNDED or DISPUTED
|
|
561
|
+
attribute :status, default: "PENDING"
|
|
562
|
+
# @!method kind
|
|
563
|
+
# @return [String] COVER or COAT_CHECK
|
|
564
|
+
attribute :kind, default: "COVER"
|
|
565
|
+
# @!method night
|
|
566
|
+
# @return [String, nil] +YYYY-MM-DD+
|
|
567
|
+
attribute :night
|
|
568
|
+
# @!method quantity
|
|
569
|
+
# @return [Integer] how many: coats, for coat check
|
|
570
|
+
attribute :quantity, :integer, default: 1
|
|
571
|
+
# @!method tier
|
|
572
|
+
# @return [String, nil]
|
|
573
|
+
attribute :tier
|
|
574
|
+
# @!method claim_check_number
|
|
575
|
+
# @return [String, nil] the coat check number to show at the counter
|
|
576
|
+
attribute :claim_check_number
|
|
577
|
+
# @!method amount
|
|
578
|
+
# @return [Money, nil]
|
|
579
|
+
attribute :amount, "Money"
|
|
580
|
+
# @!method fee
|
|
581
|
+
# @return [Money, nil]
|
|
582
|
+
attribute :fee, "Money"
|
|
583
|
+
# @!method total
|
|
584
|
+
# @return [Money, nil]
|
|
585
|
+
attribute :total, "Money"
|
|
586
|
+
# @!method refundable?
|
|
587
|
+
# @return [Boolean]
|
|
588
|
+
attribute :refundable?, :boolean, path: "isRefundable", default: false
|
|
589
|
+
# @!method pass_secret
|
|
590
|
+
# @return [String, nil] Base64; never log it. Nil once it can't get anyone in.
|
|
591
|
+
attribute :pass_secret
|
|
592
|
+
# @!method scan_count
|
|
593
|
+
# @return [Integer]
|
|
594
|
+
attribute :scan_count, :integer, default: 0
|
|
595
|
+
# @!method checked_in_at
|
|
596
|
+
# @return [Time, nil]
|
|
597
|
+
attribute :checked_in_at, :time
|
|
598
|
+
# @!method created_at
|
|
599
|
+
# @return [Time, nil]
|
|
600
|
+
attribute :created_at, :time
|
|
601
|
+
# @!method profile
|
|
602
|
+
# @return [Profile, nil] the buyer, for the door
|
|
603
|
+
attribute :profile, "Profile"
|
|
604
|
+
# @!method venue
|
|
605
|
+
# @return [Hash, nil] +id name photoUrl+
|
|
606
|
+
attribute :venue, :hash
|
|
607
|
+
# @!method event
|
|
608
|
+
# @return [Hash, nil] +id name+
|
|
609
|
+
attribute :event, :hash
|
|
610
|
+
|
|
611
|
+
# @return [Boolean] whether it's paid for and gets its holder in
|
|
612
|
+
def paid? = status == "PAID"
|
|
613
|
+
|
|
614
|
+
# The code to show at the door at +epoch_seconds+ (now by default); nil without a pass secret.
|
|
615
|
+
# @param epoch_seconds [Integer, nil]
|
|
616
|
+
# @return [String, nil]
|
|
617
|
+
def pass_code(epoch_seconds = nil) = pass_secret && CoverPass.code(id, pass_secret, epoch_seconds)
|
|
618
|
+
end
|
|
619
|
+
|
|
620
|
+
# What starting to buy cover returns: the pending admission and the payment provider's keys.
|
|
621
|
+
class CoverPurchase < Model
|
|
622
|
+
# @!method admission
|
|
623
|
+
# @return [Admission, nil]
|
|
624
|
+
attribute :admission, "Admission"
|
|
625
|
+
# @!method provider
|
|
626
|
+
# @return [String, nil] STRIPE or SQUARE
|
|
627
|
+
attribute :provider
|
|
628
|
+
# @!method payment_intent_client_secret
|
|
629
|
+
# @return [String, nil] Stripe
|
|
630
|
+
attribute :payment_intent_client_secret
|
|
631
|
+
# @!method publishable_key
|
|
632
|
+
# @return [String, nil] Stripe
|
|
633
|
+
attribute :publishable_key
|
|
634
|
+
# @!method stripe_account_id
|
|
635
|
+
# @return [String, nil] Stripe
|
|
636
|
+
attribute :stripe_account_id
|
|
637
|
+
# @!method square_application_id
|
|
638
|
+
# @return [String, nil] Square
|
|
639
|
+
attribute :square_application_id
|
|
640
|
+
# @!method square_location_id
|
|
641
|
+
# @return [String, nil] Square
|
|
642
|
+
attribute :square_location_id
|
|
643
|
+
end
|
|
644
|
+
|
|
645
|
+
# A venue's cover tonight, with the signed-in person's pass and coat check ticket.
|
|
646
|
+
class VenueCover < Model
|
|
647
|
+
# @!method id
|
|
648
|
+
# @return [String]
|
|
649
|
+
attribute :id, default: ""
|
|
650
|
+
# @!method name
|
|
651
|
+
# @return [String]
|
|
652
|
+
attribute :name, default: ""
|
|
653
|
+
# @!method charge
|
|
654
|
+
# @return [CoverCharge, nil]
|
|
655
|
+
attribute :charge, "CoverCharge", path: %w[tickets cover charge]
|
|
656
|
+
# @!method viewer_admission
|
|
657
|
+
# @return [Admission, nil]
|
|
658
|
+
attribute :viewer_admission, "Admission", path: %w[tickets cover viewerAdmission]
|
|
659
|
+
# @!method viewer_coat_check
|
|
660
|
+
# @return [Admission, nil]
|
|
661
|
+
attribute :viewer_coat_check, "Admission", path: %w[tickets cover viewerCoatCheck]
|
|
662
|
+
end
|
|
663
|
+
|
|
664
|
+
# A Soapbox publication: a newsroom, blog or columnist that publishes to the audience.
|
|
665
|
+
class Publication < Model
|
|
666
|
+
# @!method id
|
|
667
|
+
# @return [String]
|
|
668
|
+
attribute :id, default: ""
|
|
669
|
+
# @!method name
|
|
670
|
+
# @return [String]
|
|
671
|
+
attribute :name, default: ""
|
|
672
|
+
# @!method masthead
|
|
673
|
+
# @return [String, nil]
|
|
674
|
+
attribute :masthead
|
|
675
|
+
# @!method about
|
|
676
|
+
# @return [String, nil]
|
|
677
|
+
attribute :about
|
|
678
|
+
# @!method website_url
|
|
679
|
+
# @return [String, nil]
|
|
680
|
+
attribute :website_url
|
|
681
|
+
# @!method photo_url
|
|
682
|
+
# @return [String, nil]
|
|
683
|
+
attribute :photo_url
|
|
684
|
+
# @!method trusted?
|
|
685
|
+
# @return [Boolean]
|
|
686
|
+
attribute :trusted?, :boolean, path: "trusted", default: false
|
|
687
|
+
# @!method accepts_op_eds?
|
|
688
|
+
# @return [Boolean]
|
|
689
|
+
attribute :accepts_op_eds?, :boolean, path: "acceptsOpEds", default: false
|
|
690
|
+
# @!method op_ed_guidelines
|
|
691
|
+
# @return [String, nil]
|
|
692
|
+
attribute :op_ed_guidelines, path: "opEdGuidelines"
|
|
693
|
+
# @!method locale
|
|
694
|
+
# @return [Locale, nil]
|
|
695
|
+
attribute :locale, "Locale"
|
|
696
|
+
# @!method person
|
|
697
|
+
# @return [Profile, nil]
|
|
698
|
+
attribute :person, "Profile"
|
|
699
|
+
# @!method ad_free_offered?
|
|
700
|
+
# @return [Boolean] whether readers can tip to read it without ads
|
|
701
|
+
attribute :ad_free_offered?, :boolean, path: "adFreeOffered", default: false
|
|
702
|
+
# @!method ad_free_tip_cents
|
|
703
|
+
# @return [Integer, nil]
|
|
704
|
+
attribute :ad_free_tip_cents, :integer
|
|
705
|
+
# @!method ad_free_days
|
|
706
|
+
# @return [Integer, nil]
|
|
707
|
+
attribute :ad_free_days, :integer
|
|
708
|
+
end
|
|
709
|
+
|
|
710
|
+
# A Soapbox article: news a publication ran, or an op-ed a reader sent one. In a list it has its summary and
|
|
711
|
+
# teaser; read on its own ({Operations#article}) also its body and what it's about.
|
|
712
|
+
class Article < Model
|
|
713
|
+
# @!method id
|
|
714
|
+
# @return [String]
|
|
715
|
+
attribute :id, default: ""
|
|
716
|
+
# @!method slug
|
|
717
|
+
# @return [String, nil]
|
|
718
|
+
attribute :slug
|
|
719
|
+
# @!method title
|
|
720
|
+
# @return [String]
|
|
721
|
+
attribute :title, default: ""
|
|
722
|
+
# @!method summary
|
|
723
|
+
# @return [String, nil]
|
|
724
|
+
attribute :summary
|
|
725
|
+
# @!method byline
|
|
726
|
+
# @return [String, nil]
|
|
727
|
+
attribute :byline
|
|
728
|
+
# @!method kind
|
|
729
|
+
# @return [String, nil] ARTICLE or OP_ED
|
|
730
|
+
attribute :kind
|
|
731
|
+
# @!method published_at
|
|
732
|
+
# @return [Time, nil]
|
|
733
|
+
attribute :published_at, :time
|
|
734
|
+
# @!method edited?
|
|
735
|
+
# @return [Boolean] whether it changed after it ran ("Updated")
|
|
736
|
+
attribute :edited?, :boolean, path: "edited", default: false
|
|
737
|
+
# @!method pinned?
|
|
738
|
+
# @return [Boolean]
|
|
739
|
+
attribute :pinned?, :boolean, path: "pinned", default: false
|
|
740
|
+
# @!method teaser?
|
|
741
|
+
# @return [Boolean] whether only a teaser runs here and the rest is at {#canonical_url}
|
|
742
|
+
attribute :teaser?, :boolean, path: "teaser", default: false
|
|
743
|
+
# @!method canonical_url
|
|
744
|
+
# @return [String, nil]
|
|
745
|
+
attribute :canonical_url
|
|
746
|
+
# @!method disclosure
|
|
747
|
+
# @return [String, nil] a disclosure to show with it, e.g. a paid placement
|
|
748
|
+
attribute :disclosure
|
|
749
|
+
# @!method hero_photo_url
|
|
750
|
+
# @return [String, nil]
|
|
751
|
+
attribute :hero_photo_url
|
|
752
|
+
# @!method hero_alt_text
|
|
753
|
+
# @return [String, nil]
|
|
754
|
+
attribute :hero_alt_text
|
|
755
|
+
# @!method publication
|
|
756
|
+
# @return [Publication, nil]
|
|
757
|
+
attribute :publication, "Publication"
|
|
758
|
+
# @!method body
|
|
759
|
+
# @return [String, nil] read on its own: the body, as Markdown
|
|
760
|
+
attribute :body
|
|
761
|
+
# @!method viewer_ad_free?
|
|
762
|
+
# @return [Boolean] whether the signed-in reader tipped to read its publication without ads
|
|
763
|
+
attribute :viewer_ad_free?, :boolean, path: "viewerAdFree", default: false
|
|
764
|
+
# @!method featured_nationally?
|
|
765
|
+
# @return [Boolean]
|
|
766
|
+
attribute :featured_nationally?, :boolean, path: "featuredNationally", default: false
|
|
767
|
+
# @!method status
|
|
768
|
+
# @return [String, nil] an op-ed's review: SUBMITTED, DRAFT, IN_REVIEW, PUBLISHED, UNPUBLISHED or DECLINED
|
|
769
|
+
attribute :status
|
|
770
|
+
# @!method review_note
|
|
771
|
+
# @return [String, nil] the publication's note on an op-ed
|
|
772
|
+
attribute :review_note
|
|
773
|
+
# @!method submitted_at
|
|
774
|
+
# @return [Time, nil]
|
|
775
|
+
attribute :submitted_at, :time
|
|
776
|
+
|
|
777
|
+
# Read on its own: the venues, events, people and locales it is about, each +id name+.
|
|
778
|
+
# @return [Hash{String => Array<Hash>}]
|
|
779
|
+
def subjects
|
|
780
|
+
%w[venues events people locales].to_h { |key| [key, self[key]] }
|
|
781
|
+
.select { |_, list| list.is_a?(Array) }
|
|
782
|
+
.transform_values { |list| list.grep(Hash) }
|
|
783
|
+
end
|
|
784
|
+
end
|
|
785
|
+
|
|
786
|
+
# The signed-in person's calendar subscription: a feed of the events they're going to and the venues they follow.
|
|
787
|
+
class CalendarFeed < Model
|
|
788
|
+
# @return [String] the feed's https URL
|
|
789
|
+
def url = Model.cast(self["url"], :string, "")
|
|
790
|
+
|
|
791
|
+
# @return [String] the +webcal://+ link calendar apps subscribe with
|
|
792
|
+
def webcal_url = Model.cast(self["webcalUrl"], :string, nil) || url.sub(%r{\Ahttps?://}, "webcal://")
|
|
793
|
+
|
|
794
|
+
# @return [String] the link that adds it to Google Calendar
|
|
795
|
+
def google_url
|
|
796
|
+
Model.cast(self["googleUrl"], :string, nil) ||
|
|
797
|
+
"https://calendar.google.com/calendar/render?cid=#{URI.encode_www_form_component(webcal_url)}"
|
|
798
|
+
end
|
|
799
|
+
|
|
800
|
+
# @return [Array<String>] the venues it follows
|
|
801
|
+
def venue_ids = Model.hashes(self["venues"]).map { |venue| venue["id"] }.grep(String)
|
|
802
|
+
|
|
803
|
+
# @param venue_id [String]
|
|
804
|
+
# @return [Boolean]
|
|
805
|
+
def follows?(venue_id) = venue_ids.include?(venue_id)
|
|
806
|
+
end
|
|
807
|
+
|
|
808
|
+
# A venue, event or post as the audience's websites show it (+GET /v1/public/listings+). Plain text; the keys are
|
|
809
|
+
# snake_case, as the REST API sends them.
|
|
810
|
+
class PublicListing < Model
|
|
811
|
+
# @!method kind
|
|
812
|
+
# @return [String] venue, event or post
|
|
813
|
+
attribute :kind, default: ""
|
|
814
|
+
# @!method id
|
|
815
|
+
# @return [String]
|
|
816
|
+
attribute :id, default: ""
|
|
817
|
+
# @!method path
|
|
818
|
+
# @return [String, nil] its path on the audience's website
|
|
819
|
+
attribute :path
|
|
820
|
+
# @!method visibility
|
|
821
|
+
# @return [String, nil] public, or community (shown in full only to members)
|
|
822
|
+
attribute :visibility
|
|
823
|
+
# @!method title
|
|
824
|
+
# @return [String, nil]
|
|
825
|
+
attribute :title
|
|
826
|
+
# @!method description
|
|
827
|
+
# @return [String, nil]
|
|
828
|
+
attribute :description
|
|
829
|
+
# @!method address
|
|
830
|
+
# @return [String, nil]
|
|
831
|
+
attribute :address
|
|
832
|
+
# @!method phone
|
|
833
|
+
# @return [String, nil]
|
|
834
|
+
attribute :phone
|
|
835
|
+
# @!method website
|
|
836
|
+
# @return [String, nil]
|
|
837
|
+
attribute :website
|
|
838
|
+
# @!method listed
|
|
839
|
+
# @return [Boolean, nil]
|
|
840
|
+
attribute :listed, :boolean
|
|
841
|
+
# @!method image
|
|
842
|
+
# @return [String, nil]
|
|
843
|
+
attribute :image
|
|
844
|
+
# @!method start_at
|
|
845
|
+
# @return [Time, nil]
|
|
846
|
+
attribute :start_at, :time, path: "start_at"
|
|
847
|
+
# @!method end_at
|
|
848
|
+
# @return [Time, nil]
|
|
849
|
+
attribute :end_at, :time, path: "end_at"
|
|
850
|
+
# @!method venue_name
|
|
851
|
+
# @return [String, nil]
|
|
852
|
+
attribute :venue_name, path: "venue_name"
|
|
853
|
+
# @!method ticket_url
|
|
854
|
+
# @return [String, nil]
|
|
855
|
+
attribute :ticket_url, path: "ticket_url"
|
|
856
|
+
# @!method canceled
|
|
857
|
+
# @return [Boolean, nil]
|
|
858
|
+
attribute :canceled, :boolean, path: "is_canceled"
|
|
859
|
+
# @!method cover_cents
|
|
860
|
+
# @return [Integer, nil]
|
|
861
|
+
attribute :cover_cents, :integer, path: "cover_cents"
|
|
862
|
+
|
|
863
|
+
# Whether anyone may see it in full ("community" listings show in full only to members).
|
|
864
|
+
# @return [Boolean]
|
|
865
|
+
def public? = visibility.nil? || visibility == "public"
|
|
866
|
+
end
|
|
867
|
+
|
|
868
|
+
# One page of {Operations#public_listings_page}.
|
|
869
|
+
# @!attribute [r] listings
|
|
870
|
+
# @return [Array<PublicListing>]
|
|
871
|
+
# @!attribute [r] page_count
|
|
872
|
+
# @return [Integer]
|
|
873
|
+
# @!attribute [r] next_page
|
|
874
|
+
# @return [Integer, nil] the next page's number, or nil on the last page
|
|
875
|
+
PublicListingsPage = Data.define(:listings, :page_count, :next_page) do
|
|
876
|
+
# @param json [Hash]
|
|
877
|
+
# @return [PublicListingsPage]
|
|
878
|
+
def self.from_h(json)
|
|
879
|
+
new(listings: PublicListing.list(json["listings"]),
|
|
880
|
+
page_count: Model.integer(json["page_count"]) || 1, next_page: Model.integer(json["next_page"]))
|
|
881
|
+
end
|
|
882
|
+
end
|
|
883
|
+
|
|
884
|
+
# One page of {Operations#articles_page}: pass {#end_cursor} as +after:+ for the next.
|
|
885
|
+
# @!attribute [r] articles
|
|
886
|
+
# @return [Array<Article>]
|
|
887
|
+
# @!attribute [r] end_cursor
|
|
888
|
+
# @return [String, nil]
|
|
889
|
+
# @!attribute [r] next_page
|
|
890
|
+
# @return [Boolean] whether there are more
|
|
891
|
+
ArticlesPage = Data.define(:articles, :end_cursor, :next_page) do
|
|
892
|
+
# @param connection [Hash, nil] the +articles+ connection
|
|
893
|
+
# @return [ArticlesPage]
|
|
894
|
+
def self.from_connection(connection)
|
|
895
|
+
return new(articles: [], end_cursor: nil, next_page: false) unless connection.is_a?(Hash)
|
|
896
|
+
|
|
897
|
+
cursor = connection.dig("pageInfo", "endCursor")
|
|
898
|
+
more = connection.dig("pageInfo", "hasNextPage") == true && cursor.is_a?(String)
|
|
899
|
+
new(articles: Article.list(connection["nodes"]), end_cursor: more ? cursor : nil, next_page: more)
|
|
900
|
+
end
|
|
901
|
+
|
|
902
|
+
# @return [Boolean]
|
|
903
|
+
def next_page? = next_page
|
|
904
|
+
end
|
|
905
|
+
|
|
906
|
+
# Everything the audience lists, from {Operations#community}. A part whose module the audience doesn't have is
|
|
907
|
+
# empty.
|
|
908
|
+
# @!attribute [r] audience
|
|
909
|
+
# @return [Audience, nil]
|
|
910
|
+
# @!attribute [r] locales
|
|
911
|
+
# @return [Array<Locale>]
|
|
912
|
+
# @!attribute [r] venues
|
|
913
|
+
# @return [Array<Venue>]
|
|
914
|
+
# @!attribute [r] people
|
|
915
|
+
# @return [Array<Person>]
|
|
916
|
+
# @!attribute [r] events
|
|
917
|
+
# @return [Array<Event>]
|
|
918
|
+
# @!attribute [r] event_series
|
|
919
|
+
# @return [Array<EventSeries>]
|
|
920
|
+
Community = Data.define(:audience, :locales, :venues, :people, :events, :event_series)
|
|
921
|
+
|
|
922
|
+
# What {Operations#report_content} did.
|
|
923
|
+
# @!attribute [r] reported
|
|
924
|
+
# @return [Boolean]
|
|
925
|
+
# @!attribute [r] blocked
|
|
926
|
+
# @return [Boolean] whether the person behind it was blocked too
|
|
927
|
+
ReportResult = Data.define(:reported, :blocked) do
|
|
928
|
+
# @return [Boolean]
|
|
929
|
+
def reported? = reported
|
|
930
|
+
|
|
931
|
+
# @return [Boolean]
|
|
932
|
+
def blocked? = blocked
|
|
933
|
+
end
|
|
934
|
+
|
|
935
|
+
# The signed-in person's tribes and the ones they can pick from, from {Operations#tribes}.
|
|
936
|
+
# @!attribute [r] tribes
|
|
937
|
+
# @return [Array<Tag>] the tribes people can identify with here
|
|
938
|
+
# @!attribute [r] mine
|
|
939
|
+
# @return [Array<TribeIdentification>] the signed-in person's own
|
|
940
|
+
Tribes = Data.define(:tribes, :mine)
|
|
941
|
+
end
|
|
942
|
+
end
|