cobrato-client 0.2.7 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +13 -0
- data/lib/cobrato.rb +2 -0
- data/lib/cobrato/entities/remittance_cnab.rb +9 -0
- data/lib/cobrato/resources/base.rb +15 -8
- data/lib/cobrato/resources/remittance_cnab.rb +28 -0
- data/lib/cobrato/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a680b8a82eef019c7ea680ed070ea39e922b6f17
|
4
|
+
data.tar.gz: 06b9d8ffec6af5b002cc07ddb9ae438aee26ed1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db9806214d747fb5829134037a6806beb94d1aac979eb83eaddf2f879725ac023066a0c6036bfedc55c241682503f42342b3b2a9b05930b28e47b8e0fe61587a
|
7
|
+
data.tar.gz: 6633f12d129521ae63ed09a1f798d1106617314ac1baa67f323f7dd62770d80adaa3ef94c08a7c0fe8a2d66f15f26a3a975b4208e3a9e94037f53c014c06fba3
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -51,6 +51,8 @@ end
|
|
51
51
|
* [Bank Accounts API](http://docs.cobrato.com/#conta-bancária)
|
52
52
|
* [Charge Accounts API](http://docs.cobrato.com/#conta-de-cobrança)
|
53
53
|
* [Charges API](http://docs.cobrato.com/#cobrança)
|
54
|
+
* [Regress Cnab](http://docs.cobrato.com/#cnab-de-retorno)
|
55
|
+
* [Remittance Cnab](http://docs.cobrato.com/#cnab-de-remessa)
|
54
56
|
* [Webhooks API](http://docs.cobrato.com/#webhook)
|
55
57
|
|
56
58
|
## Endpoints
|
@@ -110,6 +112,17 @@ end
|
|
110
112
|
| DELETE | [api/v1/regress_cnabs/:id](http://docs.cobrato.com/#exclusão-de-cnab-de-retorno) | client.regress_cnabs.destroy |
|
111
113
|
| GET | [api/v1/regress_cnabs/:id/file](http://docs.cobrato.com/#arquivo-do-cnab-de-retorno) | client.regress_cnabs.file |
|
112
114
|
|
115
|
+
#### [Remittance Cnab](http://docs.cobrato.com/#cnab-de-remessa)
|
116
|
+
|
117
|
+
| HTTP method | Endpoint | Client method |
|
118
|
+
| ----------- | ---------------------------------------------------------------------------------------------------------------- | ------------------------------- |
|
119
|
+
| POST | [api/v1/remittance_cnabs](http://docs.cobrato.com/##criação-de-arquivo-cnab-de-remessa) | client.remittance_cnabs.create |
|
120
|
+
| GET | [api/v1/remittance_cnabs](http://docs.cobrato.com/#lista-de-todas-as-cnabs-de-remessa) | client.remittance_cnabs.list |
|
121
|
+
| GET | [api/v1/remittance_cnabs/:id](http://docs.cobrato.com/#informações-do-cnab-de-remessa) | client.remittance_cnabs.show |
|
122
|
+
| DELETE | [api/v1/remittance_cnabs/:id](http://docs.cobrato.com/#exclusão-de-cnab-de-remessa) | client.remittance_cnabs.destroy |
|
123
|
+
| GET | [api/v1/remittance_cnabs/:id/file](http://docs.cobrato.com/#arquivo-do-cnab-de-remessa) | client.remittance_cnabs.file |
|
124
|
+
| GET | [api/v1/remittance_cnabs/:id/charges](http://docs.cobrato.com/#lista-de-todas-as-cobrança-do-arquivo-de-remessa) | client.remittance_cnabs.charges |
|
125
|
+
|
113
126
|
#### [Webhooks](http://docs.cobrato.com/#webhook)
|
114
127
|
|
115
128
|
| HTTP method | Endpoint | Client method |
|
data/lib/cobrato.rb
CHANGED
@@ -15,6 +15,7 @@ require "cobrato/entities/charge"
|
|
15
15
|
require "cobrato/entities/webhook"
|
16
16
|
require "cobrato/entities/bank_billet"
|
17
17
|
require "cobrato/entities/regress_cnab"
|
18
|
+
require "cobrato/entities/remittance_cnab"
|
18
19
|
|
19
20
|
require "cobrato/resources/base"
|
20
21
|
require "cobrato/resources/payee"
|
@@ -24,6 +25,7 @@ require "cobrato/resources/charge"
|
|
24
25
|
require "cobrato/resources/webhook"
|
25
26
|
require "cobrato/resources/charging_type"
|
26
27
|
require "cobrato/resources/regress_cnab"
|
28
|
+
require "cobrato/resources/remittance_cnab"
|
27
29
|
|
28
30
|
module Cobrato
|
29
31
|
def self.configuration
|
@@ -16,7 +16,7 @@ module Cobrato
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def collection_name
|
19
|
-
@collection_name ||=
|
19
|
+
@collection_name ||= underscore_pluralized(base_klass)
|
20
20
|
end
|
21
21
|
|
22
22
|
def parsed_body(response)
|
@@ -77,11 +77,13 @@ module Cobrato
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
def respond_with_collection(response,
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
80
|
+
def respond_with_collection(response, class_name = nil)
|
81
|
+
class_name ||= base_klass
|
82
|
+
naked_klass = entity_klass(class_name)
|
83
|
+
hash = parsed_body(response)
|
84
|
+
collection_name = underscore_pluralized(class_name)
|
85
|
+
|
86
|
+
hash[collection_name].map { |item| naked_klass.new(item) }
|
85
87
|
end
|
86
88
|
|
87
89
|
def respond_with_entity(response, naked_klass = entity_klass)
|
@@ -101,8 +103,13 @@ module Cobrato
|
|
101
103
|
@base_klass ||= self.class.name.split('::').last
|
102
104
|
end
|
103
105
|
|
104
|
-
def entity_klass
|
105
|
-
@entity_klass ||= Cobrato::Entities.const_get(
|
106
|
+
def entity_klass(class_name = base_klass)
|
107
|
+
@entity_klass ||= Cobrato::Entities.const_get(class_name.to_sym)
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
def underscore_pluralized(str)
|
112
|
+
"#{str.gsub(/(.)([A-Z])/,'\1_\2').downcase}s"
|
106
113
|
end
|
107
114
|
end
|
108
115
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "cobrato/resources/hooks"
|
2
|
+
|
3
|
+
module Cobrato
|
4
|
+
module Resources
|
5
|
+
class RemittanceCnab < Base
|
6
|
+
crud :show, :list, :destroy
|
7
|
+
|
8
|
+
def create(params)
|
9
|
+
http.post(resource_base_path, { body: params }) do |response|
|
10
|
+
respond_with_collection(response)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def file(id)
|
15
|
+
http.get("#{resource_base_path}/#{id}/file") do |response|
|
16
|
+
respond_with_openstruct(response)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def charges(id)
|
21
|
+
http.get("#{resource_base_path}/#{id}/charges") do |response|
|
22
|
+
respond_with_collection(response, 'Charge')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/cobrato/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cobrato-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcio Ricardo Santos
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-01
|
13
|
+
date: 2016-02-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: typhoeus
|
@@ -198,6 +198,7 @@ files:
|
|
198
198
|
- lib/cobrato/entities/charge_account.rb
|
199
199
|
- lib/cobrato/entities/payee.rb
|
200
200
|
- lib/cobrato/entities/regress_cnab.rb
|
201
|
+
- lib/cobrato/entities/remittance_cnab.rb
|
201
202
|
- lib/cobrato/entities/webhook.rb
|
202
203
|
- lib/cobrato/exception.rb
|
203
204
|
- lib/cobrato/http.rb
|
@@ -210,6 +211,7 @@ files:
|
|
210
211
|
- lib/cobrato/resources/hooks.rb
|
211
212
|
- lib/cobrato/resources/payee.rb
|
212
213
|
- lib/cobrato/resources/regress_cnab.rb
|
214
|
+
- lib/cobrato/resources/remittance_cnab.rb
|
213
215
|
- lib/cobrato/resources/webhook.rb
|
214
216
|
- lib/cobrato/response.rb
|
215
217
|
- lib/cobrato/version.rb
|