Class: Candid::EncounterAttachments::V1::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/candid/encounter_attachments/v_1/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Candid::EncounterAttachments::V1::Client



8
9
10
# File 'lib/candid/encounter_attachments/v_1/client.rb', line 8

def initialize(client:)
  @client = client
end

Instance Method Details

#create(request_options: {}, **params) ⇒ String

Uploads a file to the encounter. The file will be stored in the encounter’s attachments. Deprecated: Use create-v2 instead.

Returns:

  • (String)


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/candid/encounter_attachments/v_1/client.rb', line 35

def create(request_options: {}, **params)
  body = Internal::Multipart::FormData.new

  body.add_part(params[:attachment_file].to_form_data_part(name: "attachment_file")) if params[:attachment_file]
  if params[:attachment_type]
    body.add(
      name: "attachment_type",
      value: params[:attachment_type]
    )
  end

  _request = Candid::Internal::Multipart::Request.new(
    method: PUT,
    path: "/api/encounter-attachments/v1/#{params[:encounter_id]}",
    body: body
  )
  begin
    _response = @client.send(_request)
  rescue Net::HTTPRequestTimeout
    raise Candid::Errors::TimeoutError
  end
  code = _response.code.to_i
  if code.between?(200, 299)
    Candid::EncounterAttachments::V1::Types::AttachmentId.load(_response.body)
  else
    error_class = Candid::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(_response.body, code: code)
  end
end

#create_with_description(request_options: {}, **params) ⇒ String

Uploads a file to the encounter. The file will be stored in the encounter’s attachments.

Returns:

  • (String)


69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/candid/encounter_attachments/v_1/client.rb', line 69

def create_with_description(request_options: {}, **params)
  body = Internal::Multipart::FormData.new

  body.add_part(params[:attachment_file].to_form_data_part(name: "attachment_file")) if params[:attachment_file]
  if params[:attachment_type]
    body.add(
      name: "attachment_type",
      value: params[:attachment_type]
    )
  end
  if params[:description]
    body.add(
      name: "description",
      value: params[:description]
    )
  end

  _request = Candid::Internal::Multipart::Request.new(
    method: PUT,
    path: "/api/encounter-attachments/v1/#{params[:encounter_id]}/v2",
    body: body
  )
  begin
    _response = @client.send(_request)
  rescue Net::HTTPRequestTimeout
    raise Candid::Errors::TimeoutError
  end
  code = _response.code.to_i
  if code.between?(200, 299)
    Candid::EncounterAttachments::V1::Types::AttachmentId.load(_response.body)
  else
    error_class = Candid::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(_response.body, code: code)
  end
end

#delete(request_options: {}, **params) ⇒ untyped

Returns:

  • (untyped)

Raises:

  • (error_class)


106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/candid/encounter_attachments/v_1/client.rb', line 106

def delete(request_options: {}, **params)
  _path_param_names = ["encounter_id"]

  _request = Candid::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Candid::Environment::PRODUCTION,
    method: "DELETE",
    path: "/api/encounter-attachments/v1/#{params[:encounter_id]}",
    body: params.except(*_path_param_names)
  )
  begin
    _response = @client.send(_request)
  rescue Net::HTTPRequestTimeout
    raise Candid::Errors::TimeoutError
  end
  code = _response.code.to_i
  return if code.between?(200, 299)

  error_class = Candid::Errors::ResponseError.subclass_for_code(code)
  raise error_class.new(_response.body, code: code)
end

#get(request_options: {}, **params) ⇒ Array[Candid::EncounterAttachments::V1::Types::EncounterAttachment]

Returns:

Raises:

  • (error_class)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/candid/encounter_attachments/v_1/client.rb', line 13

def get(request_options: {}, **params)
  _request = Candid::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Candid::Environment::PRODUCTION,
    method: "GET",
    path: "/api/encounter-attachments/v1/#{params[:encounter_id]}"
  )
  begin
    _response = @client.send(_request)
  rescue Net::HTTPRequestTimeout
    raise Candid::Errors::TimeoutError
  end
  code = _response.code.to_i
  return if code.between?(200, 299)

  error_class = Candid::Errors::ResponseError.subclass_for_code(code)
  raise error_class.new(_response.body, code: code)
end