Module: Resteze::List::ClassMethods

Defined in:
lib/resteze/list.rb

Instance Method Summary collapse

Instance Method Details

#construct_empty_listObject



17
18
19
20
# File 'lib/resteze/list.rb', line 17

def construct_empty_list
  payload = { list_key => [] }
  construct_list_from(payload)
end

#construct_list_from(payload) ⇒ Object



12
13
14
15
# File 'lib/resteze/list.rb', line 12

def construct_list_from(payload)
  values = payload.deep_symbolize_keys
  api_module::ListObject.construct_from(values, self)
end

#list(params: {}) ⇒ Object



7
8
9
10
# File 'lib/resteze/list.rb', line 7

def list(params: {})
  resp = request(list_method, list_resource_path(params), params: list_params(params))
  construct_list_from(resp.data)
end

#list_headers(_params = {}) ⇒ Object



26
27
28
# File 'lib/resteze/list.rb', line 26

def list_headers(_params = {})
  {}
end

#list_keyObject



34
35
36
# File 'lib/resteze/list.rb', line 34

def list_key
  api_module.default_list_key(self)
end

#list_methodObject



38
39
40
# File 'lib/resteze/list.rb', line 38

def list_method
  :get
end

#list_params(params = {}) ⇒ Object



22
23
24
# File 'lib/resteze/list.rb', line 22

def list_params(params = {})
  params
end

#list_resource_path(_params = {}) ⇒ Object



30
31
32
# File 'lib/resteze/list.rb', line 30

def list_resource_path(_params = {})
  resource_path
end