Class: Auth0::Branding::Themes::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/auth0/branding/themes/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void

Parameters:



10
11
12
# File 'lib/auth0/branding/themes/client.rb', line 10

def initialize(client:)
  @client = client
end

Instance Method Details

#create(request_options: {}, **params) ⇒ Auth0::Types::CreateBrandingThemeResponseContent

Create branding theme.

Examples:

client.branding.themes.create(
  borders: {
    button_border_radius: 1.1,
    button_border_weight: 1.1,
    buttons_style: "pill",
    input_border_radius: 1.1,
    input_border_weight: 1.1,
    inputs_style: "pill",
    show_widget_shadow: true,
    widget_border_weight: 1.1,
    widget_corner_radius: 1.1
  },
  colors: {
    body_text: "body_text",
    error: "error",
    header: "header",
    icons: "icons",
    input_background: "input_background",
    input_border: "input_border",
    input_filled_text: "input_filled_text",
    input_labels_placeholders: "input_labels_placeholders",
    links_focused_components: "links_focused_components",
    primary_button: "primary_button",
    primary_button_label: "primary_button_label",
    secondary_button_border: "secondary_button_border",
    secondary_button_label: "secondary_button_label",
    success: "success",
    widget_background: "widget_background",
    widget_border: "widget_border"
  },
  fonts: {
    body_text: {
      bold: true,
      size: 1.1
    },
    buttons_text: {
      bold: true,
      size: 1.1
    },
    font_url: "font_url",
    input_labels: {
      bold: true,
      size: 1.1
    },
    links: {
      bold: true,
      size: 1.1
    },
    links_style: "normal",
    reference_text_size: 1.1,
    subtitle: {
      bold: true,
      size: 1.1
    },
    title: {
      bold: true,
      size: 1.1
    }
  },
  page_background: {
    background_color: "background_color",
    background_image_url: "background_image_url",
    page_layout: "center"
  },
  widget: {
    header_text_alignment: "center",
    logo_height: 1.1,
    logo_position: "center",
    logo_url: "logo_url",
    social_buttons_layout: "bottom"
  }
)

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/auth0/branding/themes/client.rb', line 99

def create(request_options: {}, **params)
  params = Auth0::Internal::Types::Utils.normalize_keys(params)
  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "branding/themes",
    body: Auth0::Branding::Themes::Types::CreateBrandingThemeRequestContent.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Auth0::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    (response.body.to_s.empty? ? nil : Auth0::Types::CreateBrandingThemeResponseContent.load(response.body))
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#delete(request_options: {}, **params) ⇒ untyped

Delete branding theme.

Examples:

client.branding.themes.delete(theme_id: "themeId")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :theme_id (String)

Returns:

  • (untyped)

Raises:

  • (error_class)


209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/auth0/branding/themes/client.rb', line 209

def delete(request_options: {}, **params)
  params = Auth0::Internal::Types::Utils.normalize_keys(params)
  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "DELETE",
    path: "branding/themes/#{URI.encode_uri_component(params[:theme_id].to_s)}",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Auth0::Errors::TimeoutError
  end
  code = response.code.to_i
  return if code.between?(200, 299)

  error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
  raise error_class.new(response.body, code: code)
end

#get(request_options: {}, **params) ⇒ Auth0::Types::GetBrandingThemeResponseContent

Retrieve branding theme.

Examples:

client.branding.themes.get(theme_id: "themeId")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :theme_id (String)

Returns:



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/auth0/branding/themes/client.rb', line 172

def get(request_options: {}, **params)
  params = Auth0::Internal::Types::Utils.normalize_keys(params)
  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "branding/themes/#{URI.encode_uri_component(params[:theme_id].to_s)}",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Auth0::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    (response.body.to_s.empty? ? nil : Auth0::Types::GetBrandingThemeResponseContent.load(response.body))
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#get_default(request_options: {}, **_params) ⇒ Auth0::Types::GetBrandingDefaultThemeResponseContent

Retrieve default branding theme.

Examples:

client.branding.themes.get_default

Parameters:

  • request_options (Hash) (defaults to: {})
  • _params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/auth0/branding/themes/client.rb', line 136

def get_default(request_options: {}, **_params)
  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "branding/themes/default",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Auth0::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    (response.body.to_s.empty? ? nil : Auth0::Types::GetBrandingDefaultThemeResponseContent.load(response.body))
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#update(request_options: {}, **params) ⇒ Auth0::Types::UpdateBrandingThemeResponseContent

Update branding theme.

Examples:

client.branding.themes.update(
  theme_id: "themeId",
  borders: {
    button_border_radius: 1.1,
    button_border_weight: 1.1,
    buttons_style: "pill",
    input_border_radius: 1.1,
    input_border_weight: 1.1,
    inputs_style: "pill",
    show_widget_shadow: true,
    widget_border_weight: 1.1,
    widget_corner_radius: 1.1
  },
  colors: {
    body_text: "body_text",
    error: "error",
    header: "header",
    icons: "icons",
    input_background: "input_background",
    input_border: "input_border",
    input_filled_text: "input_filled_text",
    input_labels_placeholders: "input_labels_placeholders",
    links_focused_components: "links_focused_components",
    primary_button: "primary_button",
    primary_button_label: "primary_button_label",
    secondary_button_border: "secondary_button_border",
    secondary_button_label: "secondary_button_label",
    success: "success",
    widget_background: "widget_background",
    widget_border: "widget_border"
  },
  fonts: {
    body_text: {
      bold: true,
      size: 1.1
    },
    buttons_text: {
      bold: true,
      size: 1.1
    },
    font_url: "font_url",
    input_labels: {
      bold: true,
      size: 1.1
    },
    links: {
      bold: true,
      size: 1.1
    },
    links_style: "normal",
    reference_text_size: 1.1,
    subtitle: {
      bold: true,
      size: 1.1
    },
    title: {
      bold: true,
      size: 1.1
    }
  },
  page_background: {
    background_color: "background_color",
    background_image_url: "background_image_url",
    page_layout: "center"
  },
  widget: {
    header_text_alignment: "center",
    logo_height: 1.1,
    logo_position: "center",
    logo_url: "logo_url",
    social_buttons_layout: "bottom"
  }
)

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :theme_id (String)

Returns:



316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# File 'lib/auth0/branding/themes/client.rb', line 316

def update(request_options: {}, **params)
  params = Auth0::Internal::Types::Utils.normalize_keys(params)
  request_data = Auth0::Branding::Themes::Types::UpdateBrandingThemeRequestContent.new(params).to_h
  non_body_param_names = %w[themeId]
  body = request_data.except(*non_body_param_names)

  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "PATCH",
    path: "branding/themes/#{URI.encode_uri_component(params[:theme_id].to_s)}",
    body: body,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Auth0::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    (response.body.to_s.empty? ? nil : Auth0::Types::UpdateBrandingThemeResponseContent.load(response.body))
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end