Sha256: f6f8715ffe680ff28f744358a2af8851e11c046ee467ccc37f22856478516027

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

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 name notes template),
          ).serialize(resource_attributes)

          post_request "/sites", body
        end

        def update(site_id, resource_attributes)
          body = JsonApiSerializer.new(
            type: :site,
            attributes: %i(domain 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

3 entries across 3 versions & 1 rubygems

Version Path
dato-0.1.5 lib/dato/account/repo/site.rb
dato-0.1.4 lib/dato/account/repo/site.rb
dato-0.1.3 lib/dato/account/repo/site.rb