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
# File 'lib/docusign_dtr/room.rb', line 12

def all(options = {})
  options[:count] ||= MAX_ROOMS
  rooms = []
  (1..MAX_BATCHES).each do
    current_batch = batch(options)
    rooms += current_batch
    break if current_batch.size < options[:count]
  end
  rooms
end

#batch(options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/docusign_dtr/room.rb', line 23

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



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

def create(attrs = {}) end

#destroy(id) ⇒ Object



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

def destroy(id) end

#find(id) ⇒ Object



37
38
39
40
41
42
# File 'lib/docusign_dtr/room.rb', line 37

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



33
34
35
# File 'lib/docusign_dtr/room.rb', line 33

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

#update(attrs = {}) ⇒ Object



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

def update(attrs = {}) end