Class: Invofox::Document

Inherits:
Resource show all
Defined in:
lib/invofox/resources/document.rb

Class Method Summary collapse

Methods inherited from Resource

fields_information, #fields_information, has_fields, #initialize

Constructor Details

This class inherits a constructor from Invofox::Resource

Class Method Details

.bulk(company_id:, url:) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/invofox/resources/document.rb', line 35

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

.get(id:) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/invofox/resources/document.rb', line 25

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

.update(id:, data: nil, publicState: nil) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/invofox/resources/document.rb', line 51

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

.update_public_state(id:, public_state:) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/invofox/resources/document.rb', line 67

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

.update_type(id:, type:) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/invofox/resources/document.rb', line 80

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