Module: Shikimori::API::V1::Styles

Included in:
Shikimori::API::V1
Defined in:
lib/shikimori/api/v1/styles.rb

Overview

Methods for the Styles API

Instance Method Summary collapse

Instance Method Details

#create_style(style, headers: nil, **query) ⇒ Hash

Create style

Examples:

Create a red background style

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.create_style({
  name: 'Red background',
  css: 'body: { background: red !important; }',
  owner_id: 1,
  owner_type: 'User'
})

Parameters:

  • style (Hash)

    Style data for creating

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Options Hash (style):

  • :css (String)

    Style CSS content

  • :name (String)

    Style name

  • :owner_id (Integer)

    Owner ID

  • :owner_type ('User', 'Club')

    Owner type

Returns:

  • (Hash)

    Hash representing created style

See Also:



55
56
57
# File 'lib/shikimori/api/v1/styles.rb', line 55

def create_style(style, headers: nil, **query)
  rest.post base_url.join('styles').url, { style: style }, headers: headers, query: query
end

#preview_style(style, headers: nil, **query) ⇒ Hash

Preview style

Examples:

Preview style with green background

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.preview_style(
  1,
  { css: 'body: { background: green !important; }', }
)

Parameters:

  • style (Hash)

    Style data for preview

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Options Hash (style):

  • :css (String)

    Style CSS content

Returns:

  • (Hash)

    Hash representing updated style

See Also:



106
107
108
# File 'lib/shikimori/api/v1/styles.rb', line 106

def preview_style(style, headers: nil, **query)
  rest.post base_url.join('styles', 'preview').url, { style: style }, headers: headers, query: query
end

#style(id, headers: nil, **query) ⇒ Hash

Get a style

Examples:

Get a style with id equal to 1

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.style(1)

Parameters:

  • id (#to_s)

    Style id

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Returns:

  • (Hash)

    Hash representing style

See Also:



26
27
28
# File 'lib/shikimori/api/v1/styles.rb', line 26

def style(id, headers: nil, **query)
  rest.get base_url.join('styles', id.to_s).url, headers: headers, query: query
end

#update_style(id, style, headers: nil, **query) ⇒ Hash

Update style

Examples:

Change style from red background to green

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)

client.v1.update_style(
  1,
  { name: 'Green background', css: 'body: { background: green !important; }', }
)

Parameters:

  • id (Hash)

    Style’s ID

  • style (Hash)

    Style data for updating

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Options Hash (style):

  • :css (String)

    Style CSS content

  • :name (String)

    Style name

Returns:

  • (Hash)

    Hash representing updated style

See Also:



82
83
84
# File 'lib/shikimori/api/v1/styles.rb', line 82

def update_style(id, style, headers: nil, **query)
  rest.put base_url.join('styles', id.to_s).url, { style: style }, headers: headers, query: query
end