Sha256: ee00b2d9f1a0bc39a790fce9881a8b5a28e2fe56091394bff0b96fa6ae549616

Contents?: true

Size: 1.58 KB

Versions: 1

Compression:

Stored size: 1.58 KB

Contents

# -*- encoding: utf-8 -*-
require_relative 'resource'

module Contentful

  module Management

    class Locale
      include Contentful::Management::Resource
      include Contentful::Management::Resource::SystemProperties
      include Contentful::Management::Resource::Refresher

      property :code, :string
      property :name, :string
      property :contentManagementApi, :boolean
      property :contentDeliveryApi, :boolean
      property :publish, :boolean

      def self.all(space_id = nil)
        request = Request.new("/#{ space_id }/locales")
        response = request.get
        result = ResourceBuilder.new(self, response, { 'Locale' => Locale }, {})
        result.run
      end

      def self.create(space_id, attributes)
        request = Request.new("/#{ space_id }/locales", { 'name' => attributes.fetch(:name), 'code' => attributes.fetch(:code) })
        response = request.post
        result = ResourceBuilder.new(self, response, { 'Locale' => Locale }, {})
        result.run
      end

      def self.find(space_id, locale_id)
        request = Request.new("/#{ space_id }/locales/#{ locale_id }")
        response = request.get
        result = ResourceBuilder.new(self, response, { 'Locale' => Locale }, {})
        result.run
      end

      def update(attributes)
        request = Request.new("/#{ space.id }/locales/#{ id }", { 'name' => attributes.fetch(:name) }, id = nil, version: sys[:version])
        response = request.put
        result = ResourceBuilder.new(self, response, { 'Locale' => Locale }, {})
        refresh_data(result.run)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
contentful-management-0.0.1.pre lib/contentful/management/locale.rb