Class: DocusignDtr::Room

Inherits:
Object
  • Object
show all
Defined in:
lib/docusign_dtr/room.rb

Constant Summary collapse

MAX_ROOMS =
100
MAX_BATCHES =
10_000

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Room

Returns a new instance of Room.



8
9
10
# File 'lib/docusign_dtr/room.rb', line 8

def initialize(client:)
  @client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



3
4
5
# File 'lib/docusign_dtr/room.rb', line 3

def client
  @client
end

Instance Method Details

#all(options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/docusign_dtr/room.rb', line 12

def all(options = {})
  options[:count] ||= MAX_ROOMS
  options[:start_position] ||= 0
  rooms = []
  (1..MAX_BATCHES).each do
    current_batch = batch(options)
    rooms += current_batch
    options[:start_position] += options[:count]

    break if current_batch.size < options[:count]
  end
  rooms
end

#batch(options = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/docusign_dtr/room.rb', line 26

def batch(options = {})
  @client.get('/rooms', query_params(options))['rooms'].map do |room_attrs|
    room = DocusignDtr::Models::Room.new(room_attrs)
    room.client = client
    room
  end
rescue DocusignDtr::NoContent
  []
end

#create(attrs = {}) ⇒ Object



47
# File 'lib/docusign_dtr/room.rb', line 47

def create(attrs = {}) end

#destroy(id) ⇒ Object



49
# File 'lib/docusign_dtr/room.rb', line 49

def destroy(id) end

#find(id) ⇒ Object



40
41
42
43
44
45
# File 'lib/docusign_dtr/room.rb', line 40

def find(id)
  room_attrs = @client.get("/rooms/#{id}")
  room = DocusignDtr::Models::Room.new(room_attrs)
  room.client = client
  room
end

#query_params(options) ⇒ Object



36
37
38
# File 'lib/docusign_dtr/room.rb', line 36

def query_params(options)
  DocusignDtr::QueryParamHelper.call(options)
end

#update(attrs = {}) ⇒ Object



51
# File 'lib/docusign_dtr/room.rb', line 51

def update(attrs = {}) end