Sha256: 64230a3812923364f9e1e92f4d7d6ace6d6f8a052b65e07f450a1ce5dc9772aa

Contents?: true

Size: 1.2 KB

Versions: 27

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true
require 'dato/account/repo/base'

module Dato
  module Account
    module Repo
      class Site < Base
        def find(site_id)
          get_request "/sites/#{site_id}"
        end

        def all
          get_request '/sites'
        end

        def create(resource_attributes)
          body = JsonApiSerializer.new(
            type: :site,
            attributes: %i(domain internal_subdomain name notes ssg template)
          ).serialize(resource_attributes)

          post_request '/sites', body
        end

        def update(site_id, resource_attributes)
          body = JsonApiSerializer.new(
            type: :site,
            attributes: %i(domain internal_subdomain name notes)
          ).serialize(resource_attributes, site_id)

          put_request "/sites/#{site_id}", body
        end

        def destroy(site_id)
          delete_request "/sites/#{site_id}"
        end

        def duplicate(site_id, resource_attributes)
          body = JsonApiSerializer.new(
            type: :site,
            attributes: %i(name)
          ).serialize(resource_attributes)

          post_request "/sites/#{site_id}/duplicate", body
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
dato-0.3.18 lib/dato/account/repo/site.rb
dato-0.3.17 lib/dato/account/repo/site.rb
dato-0.3.16 lib/dato/account/repo/site.rb
dato-0.3.15 lib/dato/account/repo/site.rb
dato-0.3.14 lib/dato/account/repo/site.rb
dato-0.3.13 lib/dato/account/repo/site.rb
dato-0.3.12 lib/dato/account/repo/site.rb