Class: Sydecar::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/sydecar/document.rb

Constant Summary collapse

URL =
'/v1/documents'
UPLOAD_URL =
"#{URL}/upload"
SIGN_ARBITRARY_URL =
'/v1/documents/click-sign?streamable_file=true'

Class Method Summary collapse

Class Method Details

.delete(id:) ⇒ Object

Parameters:

  • id (UUID)


14
15
16
# File 'lib/sydecar/document.rb', line 14

def delete(id:)
  Connection.instance.delete("#{URL}/#{id}")
end

.download(id:) ⇒ Object



74
75
76
77
# File 'lib/sydecar/document.rb', line 74

def download(id:)
  url = download_url(id: id)
  Connection.instance.get(url)
end

.download_url(id:) ⇒ Object



70
71
72
# File 'lib/sydecar/document.rb', line 70

def download_url(id:)
  "/v1/documents/#{id}/get_download_url"
end

.find(id:) ⇒ Object

Parameters:

  • id (UUID)


10
11
12
# File 'lib/sydecar/document.rb', line 10

def find(id:)
  Connection.instance.get("#{URL}/#{id}")
end

.find_all(params: {}, body: {}) ⇒ Object

String

sort: asc / desc

Integer

limit

Integer

offset

String

start_date (format: yyyy-mm-dd)

String

end_date (format: yyyy-mm-dd)

Parameters:

  • params (Hash) (defaults to: {})

    argument expects to have the following keys:

  • body: (Hash) (defaults to: {})

    expects to have “ids” key



64
65
66
67
68
# File 'lib/sydecar/document.rb', line 64

def find_all(params: {}, body: {})
  query = '?'
  query += URI.encode_www_form(params)
  Connection.instance.post("#{URL}#{query}", body)
end

.preview(id:, body:) ⇒ Object

Parameters:

  • id (UUID)
  • body (Hash)


25
26
27
28
# File 'lib/sydecar/document.rb', line 25

def preview(id:, body:)
  url = preview_url(id: id)
  Connection.instance.post(url, body)
end

.preview_url(id:) ⇒ Object

Parameters:

  • id (UUID)


19
20
21
# File 'lib/sydecar/document.rb', line 19

def preview_url(id:)
  "/v1/documents/#{id}/preview?streamable_file=false"
end

.required_fields(id:) ⇒ Object

Parameters:

  • id (UUID)


48
49
50
51
# File 'lib/sydecar/document.rb', line 48

def required_fields(id:)
  url = required_fields_url(id: id)
  Connection.instance.get(url)
end

.required_fields_url(id:) ⇒ Object

Parameters:

  • id (UUID)


43
44
45
# File 'lib/sydecar/document.rb', line 43

def required_fields_url(id:)
  "/v1/documents/#{id}/fields"
end

.sign(id:, body:) ⇒ Object

Parameters:

  • id (UUID)
  • body (Hash)


37
38
39
40
# File 'lib/sydecar/document.rb', line 37

def sign(id:, body:)
  url = sign_url(id: id)
  Connection.instance.post(url, body)
end

.sign_arbitrary(body:, idempotency_key:) ⇒ Object



53
54
55
# File 'lib/sydecar/document.rb', line 53

def sign_arbitrary(body:, idempotency_key:)
  Connection.instance.post(SIGN_ARBITRARY_URL, body, { 'idempotency-key': idempotency_key })
end

.sign_url(id:) ⇒ Object

Parameters:

  • id (UUID)


31
32
33
# File 'lib/sydecar/document.rb', line 31

def sign_url(id:)
  "/v1/documents/#{id}/click-sign?streamable_file=false"
end

.upload(body:, idempotency_key:) ⇒ Object



79
80
81
# File 'lib/sydecar/document.rb', line 79

def upload(body:, idempotency_key:)
  FileConnection.instance.post(UPLOAD_URL, body, { 'idempotency-key': idempotency_key })
end