Sha256: 84925a82823c31cf34c6edd461606c67a35120f15d41cef99b37b2846bee3c64

Contents?: true

Size: 1.75 KB

Versions: 1

Compression:

Stored size: 1.75 KB

Contents

class Invofox::Document < Invofox::Resource
  has_fields company:        :string,
             creator:        :string,
             creation:       :time,
             name:           :string,
             type:           :string,
             clientData:     :hash,
             images:         :array,
             original:       :string,
             mimetype:       :string,
             data:           :hash,
             publicState:    :string,
             confidence:     :high,
             validationInfo: :hash,
             approvalInfo:   :hash,
             approvedBy:     :array,
             requiredSigns:  :array,
             import:         :hash,
             exports:        :array,
             archived:       :boolean,
             geometry:       :hash,
             skippedBy:      :array

  class << self
    def get(id:)
      Invofox.api_call(
        clazz:  self,
        method: :get,
        path:   "/documents/#{id}"
      ) do |response_body|
        response_body['result']
      end
    end

    def bulk(company_id:, url:)
      Invofox.api_call(
        clazz:  Invofox::LoadBatch,
        method: :post,
        path:   '/documents/bulk',
        params: {
          company:       company_id,
          urls:          url,
          closeBatch:    true,
          useClassifier: true
        }
      ) do |response_body|
        response_body['result']['loadBatch']
      end
    end

    def update(id:, data: nil, publicState: nil)
      payload = {
        data:        data,
        publicState: publicState
      }.compact

      Invofox.api_call(
        clazz:  self,
        method: :put,
        path:   "/documents/#{id}",
        params: payload
      ) do |response_body|
        response_body['result']
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
invofox-api-ruby-0.1.0 lib/invofox/resources/document.rb