Class: Believe::Resources::Quotes

Inherits:
Object
  • Object
show all
Defined in:
lib/believe/resources/quotes.rb

Overview

Memorable quotes from the show

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Quotes

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Quotes.

Parameters:



253
254
255
# File 'lib/believe/resources/quotes.rb', line 253

def initialize(client:)
  @client = client
end

Instance Method Details

#create(character_id:, context:, moment_type:, text:, theme:, episode_id: nil, is_funny: nil, is_inspirational: nil, popularity_score: nil, secondary_themes: nil, times_shared: nil, request_options: {}) ⇒ ::Believe::Models::Quote

Add a new memorable quote to the collection.

Parameters:

  • character_id (String)

    ID of the character who said it

  • context (String)

    Context in which the quote was said

  • moment_type (Symbol, ::Believe::Models::QuoteMoment)

    Type of moment when the quote was said

  • text (String)

    The quote text

  • theme (Symbol, ::Believe::Models::QuoteTheme)

    Primary theme of the quote

  • episode_id (String, nil)

    Episode where the quote appears

  • is_funny (Boolean)

    Whether this quote is humorous

  • is_inspirational (Boolean)

    Whether this quote is inspirational

  • popularity_score (Float, nil)

    Popularity/virality score (0-100)

  • secondary_themes (Array<Symbol, ::Believe::Models::QuoteTheme>)

    Additional themes

  • times_shared (Integer, nil)

    Number of times shared on social media

  • request_options (::Believe::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



38
39
40
41
42
43
44
45
46
47
# File 'lib/believe/resources/quotes.rb', line 38

def create(params)
  parsed, options = ::Believe::QuoteCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "quotes",
    body: parsed,
    model: ::Believe::Quote,
    options: options
  )
end

#delete(quote_id, request_options: {}) ⇒ nil

Remove a quote from the collection.

Parameters:

Returns:

  • (nil)

See Also:



158
159
160
161
162
163
164
165
# File 'lib/believe/resources/quotes.rb', line 158

def delete(quote_id, params = {})
  @client.request(
    method: :delete,
    path: ["quotes/%1$s", quote_id],
    model: NilClass,
    options: params[:request_options]
  )
end

#get_random(character_id: nil, inspirational: nil, theme: nil, request_options: {}) ⇒ ::Believe::Models::Quote

Get a random Ted Lasso quote, optionally filtered.

Parameters:

Returns:

See Also:



182
183
184
185
186
187
188
189
190
191
192
# File 'lib/believe/resources/quotes.rb', line 182

def get_random(params = {})
  parsed, options = ::Believe::QuoteGetRandomParams.dump_request(params)
  query = ::Believe::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "quotes/random",
    query: query,
    model: ::Believe::Quote,
    options: options
  )
end

#list(character_id: nil, funny: nil, inspirational: nil, limit: nil, moment_type: nil, skip: nil, theme: nil, request_options: {}) ⇒ ::Believe::Internal::SkipLimitPage<::Believe::Models::Quote>

Get a paginated list of all memorable Ted Lasso quotes with optional filtering.

Parameters:

  • character_id (String, nil)

    Filter by character

  • funny (Boolean, nil)

    Filter funny quotes

  • inspirational (Boolean, nil)

    Filter inspirational quotes

  • limit (Integer)

    Maximum number of items to return (max: 100)

  • moment_type (Symbol, ::Believe::Models::QuoteMoment, nil)

    Filter by moment type

  • skip (Integer)

    Number of items to skip (offset)

  • theme (Symbol, ::Believe::Models::QuoteTheme, nil)

    Filter by theme

  • request_options (::Believe::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/believe/resources/quotes.rb', line 135

def list(params = {})
  parsed, options = ::Believe::QuoteListParams.dump_request(params)
  query = ::Believe::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "quotes",
    query: query,
    page: ::Believe::Internal::SkipLimitPage,
    model: ::Believe::Quote,
    options: options
  )
end

#list_by_character(character_id, limit: nil, skip: nil, request_options: {}) ⇒ ::Believe::Internal::SkipLimitPage<::Believe::Models::Quote>

Get a paginated list of quotes from a specific character.

Parameters:

  • character_id (String)
  • limit (Integer)

    Maximum number of items to return (max: 100)

  • skip (Integer)

    Number of items to skip (offset)

  • request_options (::Believe::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/believe/resources/quotes.rb', line 209

def list_by_character(character_id, params = {})
  parsed, options = ::Believe::QuoteListByCharacterParams.dump_request(params)
  query = ::Believe::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["quotes/characters/%1$s", character_id],
    query: query,
    page: ::Believe::Internal::SkipLimitPage,
    model: ::Believe::Quote,
    options: options
  )
end

#list_by_theme(theme, limit: nil, skip: nil, request_options: {}) ⇒ ::Believe::Internal::SkipLimitPage<::Believe::Models::Quote>

Get a paginated list of quotes related to a specific theme.

Parameters:

  • theme (Symbol, ::Believe::Models::QuoteTheme)

    Themes that quotes can be categorized under.

  • limit (Integer)

    Maximum number of items to return (max: 100)

  • skip (Integer)

    Number of items to skip (offset)

  • request_options (::Believe::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/believe/resources/quotes.rb', line 237

def list_by_theme(theme, params = {})
  parsed, options = ::Believe::QuoteListByThemeParams.dump_request(params)
  query = ::Believe::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["quotes/themes/%1$s", theme],
    query: query,
    page: ::Believe::Internal::SkipLimitPage,
    model: ::Believe::Quote,
    options: options
  )
end

#retrieve(quote_id, request_options: {}) ⇒ ::Believe::Models::Quote

Retrieve a specific quote by its ID.

Parameters:

Returns:

See Also:



59
60
61
62
63
64
65
66
# File 'lib/believe/resources/quotes.rb', line 59

def retrieve(quote_id, params = {})
  @client.request(
    method: :get,
    path: ["quotes/%1$s", quote_id],
    model: ::Believe::Quote,
    options: params[:request_options]
  )
end

#update(quote_id, character_id: nil, context: nil, episode_id: nil, is_funny: nil, is_inspirational: nil, moment_type: nil, popularity_score: nil, secondary_themes: nil, text: nil, theme: nil, times_shared: nil, request_options: {}) ⇒ ::Believe::Models::Quote

Update specific fields of an existing quote.

Parameters:

Returns:

See Also:



101
102
103
104
105
106
107
108
109
110
# File 'lib/believe/resources/quotes.rb', line 101

def update(quote_id, params = {})
  parsed, options = ::Believe::QuoteUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["quotes/%1$s", quote_id],
    body: parsed,
    model: ::Believe::Quote,
    options: options
  )
end