Class: Candid::PreEncounter::Notes::V1::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Candid::PreEncounter::Notes::V1::Client



9
10
11
# File 'lib/candid/pre_encounter/notes/v_1/client.rb', line 9

def initialize(client:)
  @client = client
end

Instance Method Details

#create(request_options: {}, **params) ⇒ Candid::PreEncounter::Notes::V1::Types::Note

Adds a new note.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/candid/pre_encounter/notes/v_1/client.rb', line 39

def create(request_options: {}, **params)
  _request = Candid::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Candid::Environment::PRODUCTION,
    method: "POST",
    path: "/notes/v1",
    body: Candid::PreEncounter::Notes::V1::Types::MutableNote.new(params).to_h
  )
  begin
    _response = @client.send(_request)
  rescue Net::HTTPRequestTimeout
    raise Candid::Errors::TimeoutError
  end
  code = _response.code.to_i
  if code.between?(200, 299)
    Candid::PreEncounter::Notes::V1::Types::Note.load(_response.body)
  else
    error_class = Candid::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(_response.body, code: code)
  end
end

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

Sets a note as deactivated. The path must contain the most recent version to prevent races.

Raises:

  • (error_class)


87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/candid/pre_encounter/notes/v_1/client.rb', line 87

def deactivate(request_options: {}, **params)
  _request = Candid::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Candid::Environment::PRODUCTION,
    method: "DELETE",
    path: "/notes/v1/#{params[:id]}/#{params[:version]}"
  )
  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) ⇒ Candid::PreEncounter::Notes::V1::Types::Note

Gets a note by NoteId.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/candid/pre_encounter/notes/v_1/client.rb', line 16

def get(request_options: {}, **params)
  _request = Candid::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Candid::Environment::PRODUCTION,
    method: "GET",
    path: "/notes/v1/#{params[:id]}"
  )
  begin
    _response = @client.send(_request)
  rescue Net::HTTPRequestTimeout
    raise Candid::Errors::TimeoutError
  end
  code = _response.code.to_i
  if code.between?(200, 299)
    Candid::PreEncounter::Notes::V1::Types::Note.load(_response.body)
  else
    error_class = Candid::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(_response.body, code: code)
  end
end

#update(request_options: {}, **params) ⇒ Candid::PreEncounter::Notes::V1::Types::Note

Updates a note. The path must contain the most recent version to prevent races.



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/candid/pre_encounter/notes/v_1/client.rb', line 63

def update(request_options: {}, **params)
  _request = Candid::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Candid::Environment::PRODUCTION,
    method: "PUT",
    path: "/notes/v1/#{params[:id]}/#{params[:version]}",
    body: Candid::PreEncounter::Notes::V1::Types::MutableNote.new(params).to_h
  )
  begin
    _response = @client.send(_request)
  rescue Net::HTTPRequestTimeout
    raise Candid::Errors::TimeoutError
  end
  code = _response.code.to_i
  if code.between?(200, 299)
    Candid::PreEncounter::Notes::V1::Types::Note.load(_response.body)
  else
    error_class = Candid::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(_response.body, code: code)
  end
end