Class: Cobrato::Resources::RemittanceCnab
- Inherits:
-
Base
- Object
- Base
- Cobrato::Resources::RemittanceCnab
show all
- Defined in:
- lib/cobrato/resources/remittance_cnab.rb
Instance Attribute Summary
Attributes inherited from Base
#http
Instance Method Summary
collapse
Methods inherited from Base
#collection_name, crud, #destroy, #initialize, #list, #parsed_body, #show, #update
Methods included from Hooks
#notify
Instance Method Details
#charges(id) ⇒ Object
21
22
23
24
25
26
|
# File 'lib/cobrato/resources/remittance_cnab.rb', line 21
def charges(id)
puts "Warning: The 'charges' endpoint is deprecated. Use 'items' endpoint instead."
http.get("#{resource_base_path}/#{id}/charges") do |response|
respond_with_collection(response, 'Charge')
end
end
|
#create(params) ⇒ Object
8
9
10
11
12
13
|
# File 'lib/cobrato/resources/remittance_cnab.rb', line 8
def create(params)
deprecate(params, %w[charge_ids charge_config_ids])
http.post(resource_base_path, { body: params }) do |response|
respond_with_collection(response)
end
end
|
#file(id) ⇒ Object
15
16
17
18
19
|
# File 'lib/cobrato/resources/remittance_cnab.rb', line 15
def file(id)
http.get("#{resource_base_path}/#{id}/file") do |response|
respond_with_openstruct(response)
end
end
|
#items(id) ⇒ Object
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/cobrato/resources/remittance_cnab.rb', line 28
def items(id)
http.get("#{resource_base_path}/#{id}/items") do |response|
hash = parsed_body(response)
collection_name = hash.keys.first
class_name = collection_name.gsub(/(.)(.*)s/) { "#{$1.upcase}#{$2}" }
naked_klass = entity_klass(class_name)
hash[collection_name].map { |item| naked_klass.new(item) }
end
end
|