Class: PagiiiApi::Theme

Inherits:
Object
  • Object
show all
Defined in:
lib/pagiii_api/theme.rb

Class Method Summary collapse

Class Method Details

.create(options) ⇒ Object

Arguments: name



5
6
7
8
9
10
11
12
13
14
# File 'lib/pagiii_api/theme.rb', line 5

def create(options)
  conn = Pagiii.create_connection

  response = conn.post("/api/v1/admin/themes") do |req|
    req.body = {
      theme: options
    }.to_json
  end
  Pagiii.build_response(response)
end

.list(page = 1) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/pagiii_api/theme.rb', line 16

def list(page = 1)
  conn = Pagiii.create_connection

  response = conn.get("/api/v1/admin/themes") do |req|
    req.params['page'] = page
  end

  Pagiii.build_response(response)
end

.set_current(theme_id) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/pagiii_api/theme.rb', line 26

def set_current(theme_id)
  conn = Pagiii.create_connection

  response = conn.patch("/api/v1/admin/themes/#{theme_id}/set_current") do |req|
    req.body = {}.to_json
  end
  Pagiii.build_response(response)
end

.upload(path) ⇒ Object



35
36
37
38
39
40
# File 'lib/pagiii_api/theme.rb', line 35

def upload(path)
  conn = Pagiii.create_upload_connection
  payload = { file: Faraday::FilePart.new(path, 'application/zip') }
  response = conn.post("/api/v1/admin/themes/upload", payload)
  Pagiii.build_response(response)
end