Sha256: b24af9c9d8357e54ee74a6d3e7a773ee2950eafcc3742bed57175b9e816aef6c

Contents?: true

Size: 981 Bytes

Versions: 2

Compression:

Stored size: 981 Bytes

Contents

require 'forwardable'
require 'kintone/api'
require 'kintone/command/accessor'

class Kintone::Api
  class Guest
    extend Forwardable

    GUEST_PATH = '/k/guest/%s/v1/'
    ACCESSIBLE_COMMAND = [
      :record,
      :records,
      :form,
      :app_acl,
      :record_acl,
      :field_acl,
      :space,
      :space_body,
      :space_thread,
      :space_members,
      :space_guests,
      :app,
      :apps,
      :bulk_request,
      :bulk,
      :file
    ].freeze

    def_delegators :@api, :get, :post, :put, :delete, :post_file

    def initialize(space_id, api)
      @api = api
      @guest_path = GUEST_PATH % space_id
    end

    def get_url(command)
      @guest_path + (COMMAND % command)
    end

    def method_missing(name, *args)
      if ACCESSIBLE_COMMAND.include?(name)
        CommandAccessor.send(name, self)
      else
        super(name, *args)
      end
    end

    class CommandAccessor
      extend Kintone::Command::Accessor
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kintone-0.1.4 lib/kintone/api/guest.rb
kintone-0.1.3 lib/kintone/api/guest.rb