module FileboundClient::Endpoints

Module for resource endpoints

Public Class Methods

allow_all(name) click to toggle source

@!macro [attach] fb.allow_all Returns an array $1 hashes @param [Hash] query_params params to pass to the request @return [Array] an array of $1 hashes

# File lib/filebound_client/endpoints.rb, line 23
def self.allow_all(name)
  define_method(name.to_s) do |query_params = nil|
    get("/#{name}", query_params)
  end
end
allow_new(name) click to toggle source

@!macro [attach] fb.allow_new Returns a new empty resource with defaulted values @return [Hash] a new hash of $1

# File lib/filebound_client/endpoints.rb, line 13
def self.allow_new(name)
  define_method("#{name}_new") do
    get('/empty', template: name.to_s)
  end
end
included(klass) click to toggle source

Sets up macros for use by endpoints and includes all endpoints rubocop:disable Metrics/MethodLength, Metrics/AbcSize

# File lib/filebound_client/endpoints.rb, line 8
def self.included(klass)
  klass.instance_eval do
    # @!macro [attach] fb.allow_new
    # Returns a new empty resource with defaulted values
    # @return [Hash] a new hash of $1
    def self.allow_new(name)
      define_method("#{name}_new") do
        get('/empty', template: name.to_s)
      end
    end

    # @!macro [attach] fb.allow_all
    # Returns an array $1 hashes
    # @param [Hash] query_params params to pass to the request
    # @return [Array] an array of $1 hashes
    def self.allow_all(name)
      define_method(name.to_s) do |query_params = nil|
        get("/#{name}", query_params)
      end
    end
  end

  klass.class_eval do
    include FileboundClient::Endpoints::Projects
    include FileboundClient::Endpoints::Files
    include FileboundClient::Endpoints::Documents
    include FileboundClient::Endpoints::Version
    include FileboundClient::Endpoints::Assignments
    include FileboundClient::Endpoints::Dividers
    include FileboundClient::Endpoints::DocumentBinaryData
    include FileboundClient::Endpoints::EFormData
    include FileboundClient::Endpoints::EFormDetail
    include FileboundClient::Endpoints::Separators
    include FileboundClient::Endpoints::Query
    include FileboundClient::Endpoints::Users
    include FileboundClient::Endpoints::Routes
    include FileboundClient::Endpoints::RoutedItems
    include FileboundClient::Endpoints::Groups
  end
end