Module: FileboundClient::Endpoints

Included in:
Client
Defined in:
lib/filebound_client/endpoints.rb,
lib/filebound_client/endpoints/files.rb,
lib/filebound_client/endpoints/query.rb,
lib/filebound_client/endpoints/version.rb,
lib/filebound_client/endpoints/dividers.rb,
lib/filebound_client/endpoints/projects.rb,
lib/filebound_client/endpoints/documents.rb,
lib/filebound_client/endpoints/eform_data.rb,
lib/filebound_client/endpoints/separators.rb,
lib/filebound_client/endpoints/assignments.rb,
lib/filebound_client/endpoints/eform_detail.rb,
lib/filebound_client/endpoints/document_binary_data.rb

Overview

Module for resource endpoints

Defined Under Namespace

Modules: Assignments, Dividers, DocumentBinaryData, Documents, EFormData, EFormDetail, Files, Projects, Query, Separators, Version

Class Method Summary collapse

Class Method Details

.included(klass) ⇒ Object

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



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/filebound_client/endpoints.rb', line 17

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::Separators
    include FileboundClient::Endpoints::Query
  end
end