-
Notifications
You must be signed in to change notification settings - Fork 128
Expand file tree
/
Copy pathredirect.rb
More file actions
43 lines (35 loc) · 848 Bytes
/
redirect.rb
File metadata and controls
43 lines (35 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require 'bigcommerce'
Bigcommerce.configure do |config|
config.store_hash = ENV['BC_STORE_HASH']
config.client_id = ENV['BC_CLIENT_ID']
config.access_token = ENV['BC_ACCESS_TOKEN']
end
# List redirects
@redirects = Bigcommerce::Redirect.all(page: 1)
puts @redirects
# Get a redirect
puts Bigcommerce::Redirect.find(@redirects[0].id)
# Get a count of redirects
puts Bigcommerce::Redirect.count
# Create a redirect
@redirect = Bigcommerce::Redirect.create(
path: '/womens_clothing',
forward: {
type: 'category',
ref: 3
}
)
puts @redirect
# Update a redirect
puts Bigcommerce::Redirect.update(
@redirect.id,
path: '/womens_clothing',
forward: {
type: 'category',
ref: 3
}
)
# Delete a redirect
puts Bigcommerce::Redirect.destroy(@redirect.id)
# Delete all redirects
# puts Bigcommerce::Redirect.destroy_all