Sha256: 1b0047c5791cfc19451ed7b0a1b7029eadcb33cc2f55d418a870a05a9671708d

Contents?: true

Size: 1000 Bytes

Versions: 1

Compression:

Stored size: 1000 Bytes

Contents

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

class Kintone::Api
  class Guest
    extend Forwardable

    GUEST_PATH = '/k/guest/%s/v1/'.freeze
    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, :preview_form
    ].freeze

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

    def initialize(space_id, api)
      @api = api
      @guest_path = GUEST_PATH % space_id.to_i
    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
      end
    end

    def respond_to_missing?(name, *args)
      ACCESSIBLE_COMMAND.include?(name) || super
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kintone_rb-1.0.1 lib/kintone/api/guest.rb