Class: HubSpotSDK::Resources::Cms::URLRedirects

Inherits:
Object
  • Object
show all
Defined in:
lib/hubspot_sdk/resources/cms/url_redirects.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ URLRedirects

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 URLRedirects.

Parameters:



200
201
202
# File 'lib/hubspot_sdk/resources/cms/url_redirects.rb', line 200

def initialize(client:)
  @client = client
end

Instance Method Details

#create(destination:, redirect_style:, route_prefix:, is_match_full_url: nil, is_match_query_string: nil, is_only_after_not_found: nil, is_pattern: nil, is_protocol_agnostic: nil, is_trailing_slash_optional: nil, precedence: nil, request_options: {}) ⇒ HubSpotSDK::Models::Cms::URLMapping

Some parameter documentations has been truncated, see Models::Cms::URLRedirectCreateParams for more details.

Create a new URL redirect in your HubSpot account. This endpoint allows you to define a new URL mapping that redirects traffic from a specified route to a destination URL. This is useful for managing URL changes, handling outdated links, or creating short links.

Parameters:

  • destination (String)

    The destination URL, where the target URL should be redirected if it matches the

  • redirect_style (Integer)

    The type of redirect to create. Options include: 301 (permanent), 302 (temporary

  • route_prefix (String)

    The target incoming URL, path, or pattern to match for redirection.

  • is_match_full_url (Boolean)

    Whether the ‘routePrefix` should match on the entire URL, including the domain.

  • is_match_query_string (Boolean)

    Whether the ‘routePrefix` should match on the entire URL path, including the que

  • is_only_after_not_found (Boolean)

    Whether the URL redirect mapping should apply only if a live page on the URL isn

  • is_pattern (Boolean)

    Whether the ‘routePrefix` should match based on pattern.

  • is_protocol_agnostic (Boolean)

    Whether the ‘routePrefix` should match both HTTP and HTTPS protocols.

  • is_trailing_slash_optional (Boolean)

    Whether a trailing slash will be ignored.

  • precedence (Integer)

    Used to prioritize URL redirection. If a given URL matches more than one redirec

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

Returns:

See Also:



42
43
44
45
46
47
48
49
50
51
# File 'lib/hubspot_sdk/resources/cms/url_redirects.rb', line 42

def create(params)
  parsed, options = HubSpotSDK::Cms::URLRedirectCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "cms/url-redirects/2026-03",
    body: parsed,
    model: HubSpotSDK::Cms::URLMapping,
    options: options
  )
end

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

Delete one existing redirect, so it is no longer mapped.

Parameters:

Returns:

  • (nil)

See Also:



169
170
171
172
173
174
175
176
# File 'lib/hubspot_sdk/resources/cms/url_redirects.rb', line 169

def delete(url_redirect_id, params = {})
  @client.request(
    method: :delete,
    path: ["cms/url-redirects/2026-03/%1$s", url_redirect_id],
    model: NilClass,
    options: params[:request_options]
  )
end

#get(url_redirect_id, request_options: {}) ⇒ HubSpotSDK::Models::Cms::URLMapping

Returns the details for a single existing URL redirect by ID.

Parameters:

Returns:

See Also:



188
189
190
191
192
193
194
195
# File 'lib/hubspot_sdk/resources/cms/url_redirects.rb', line 188

def get(url_redirect_id, params = {})
  @client.request(
    method: :get,
    path: ["cms/url-redirects/2026-03/%1$s", url_redirect_id],
    model: HubSpotSDK::Cms::URLMapping,
    options: params[:request_options]
  )
end

#list(after: nil, archived: nil, created_after: nil, created_at: nil, created_before: nil, limit: nil, sort: nil, updated_after: nil, updated_at: nil, updated_before: nil, request_options: {}) ⇒ HubSpotSDK::Internal::Page<HubSpotSDK::Models::Cms::URLMapping>

Some parameter documentations has been truncated, see Models::Cms::URLRedirectListParams for more details.

Retrieve a list of URL redirects configured in your HubSpot account. This endpoint allows you to filter redirects based on their creation or update timestamps, and sort the results. It supports pagination and can include archived redirects if specified.

Parameters:

  • after (String)

    The paging cursor token of the last successfully read resource will be returned

  • archived (Boolean)

    Whether to return only results that have been archived.

  • created_after (Time)
  • created_at (Time)
  • created_before (Time)
  • limit (Integer)

    The maximum number of results to display per page.

  • sort (Array<String>)
  • updated_after (Time)
  • updated_at (Time)
  • updated_before (Time)
  • request_options (HubSpotSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/hubspot_sdk/resources/cms/url_redirects.rb', line 139

def list(params = {})
  parsed, options = HubSpotSDK::Cms::URLRedirectListParams.dump_request(params)
  query = HubSpotSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "cms/url-redirects/2026-03",
    query: query.transform_keys(
      created_after: "createdAfter",
      created_at: "createdAt",
      created_before: "createdBefore",
      updated_after: "updatedAfter",
      updated_at: "updatedAt",
      updated_before: "updatedBefore"
    ),
    page: HubSpotSDK::Internal::Page,
    model: HubSpotSDK::Cms::URLMapping,
    options: options
  )
end

#update(url_redirect_id, id:, created:, destination:, is_match_full_url:, is_match_query_string:, is_only_after_not_found:, is_pattern:, is_protocol_agnostic:, is_trailing_slash_optional:, precedence:, redirect_style:, route_prefix:, updated:, request_options: {}) ⇒ HubSpotSDK::Models::Cms::URLMapping

Some parameter documentations has been truncated, see Models::Cms::URLRedirectUpdateParams for more details.

Updates the settings for an existing URL redirect.

Parameters:

  • url_redirect_id (String)
  • id (String)

    The unique ID of this URL redirect.

  • created (Time)

    The date and time when the URL mapping was initially created.

  • destination (String)

    The destination URL, where the target URL should be redirected if it matches the

  • is_match_full_url (Boolean)

    Whether the ‘routePrefix` should match on the entire URL, including the domain.

  • is_match_query_string (Boolean)

    Whether the ‘routePrefix` should match on the entire URL path, including the que

  • is_only_after_not_found (Boolean)

    Whether the URL redirect mapping should apply only if a live page on the URL isn

  • is_pattern (Boolean)

    Whether the ‘routePrefix` should match based on pattern.

  • is_protocol_agnostic (Boolean)

    Whether the ‘routePrefix` should match both HTTP and HTTPS protocols.

  • is_trailing_slash_optional (Boolean)

    Whether a trailing slash will be ignored.

  • precedence (Integer)

    Used to prioritize URL redirection. If a given URL matches more than one redirec

  • redirect_style (Integer)

    The type of redirect to create. Options include: 301 (permanent), 302 (temporary

  • route_prefix (String)

    The target incoming URL, path, or pattern to match for redirection.

  • updated (Time)

    The date and time when the URL mapping was last modified.

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

Returns:

See Also:



93
94
95
96
97
98
99
100
101
102
# File 'lib/hubspot_sdk/resources/cms/url_redirects.rb', line 93

def update(url_redirect_id, params)
  parsed, options = HubSpotSDK::Cms::URLRedirectUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["cms/url-redirects/2026-03/%1$s", url_redirect_id],
    body: parsed,
    model: HubSpotSDK::Cms::URLMapping,
    options: options
  )
end