cobrato-client 0.23.0.beta1 → 0.23.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e7216fb3d6fe900e969637ea6aa7916fa7e8753c
4
- data.tar.gz: e623af51e75b8aa84b4894ec0bcc387ed49c8d40
3
+ metadata.gz: 3332c2210e9647bbf533b15b7b70ac101fc7006f
4
+ data.tar.gz: 24e0355957b7f6c31d0a26f818a7b49ff1a633db
5
5
  SHA512:
6
- metadata.gz: d295d4b3db65f98cac28c9c6ffbf4547da9dbcbcede9cca1e4bbb88f7e9ce88fe7c846ea17dca223259e3abbf09476fa7d35a083cec4376ebb3c31465c2b64e9
7
- data.tar.gz: 63822c73847f449de0097d3ac6586fbbb23ee46561cdcb9ac6a8c6f99897865db1beb72be011f465b90f9b672a73908feb2332a3dde0d162e1fe7af86fd5a995
6
+ metadata.gz: a71c48324a9a4f3e024e6fe29ade670f11ef905174d85eee6705c72f8a4458c9dc2915dc33b5dfc0d96a03904f5a8eb367f6dd5526aada18084b1d28af89a5d0
7
+ data.tar.gz: eb9b0d82304d0629ed7e22ffa4548f7ef6c1fdd1695931168c10812a214d53c438cb3fc172e90517dfe8157e6654542cb299bd76297894ee588c9f270657b4f1
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## Next version
4
4
 
5
+ ## v0.23.0.beta2
6
+
7
+ - Add Payment API support.
8
+ - Add changes on RemittanceCnab API:
9
+ - `remittance_cnabs#charges` is now DEPRECATED. Use `remittance_cnabs#items` instead.
10
+ - The use of `charge_config_ids` and `charge_ids` for RemittanceCnab creation is now DEPRECATED. Use `config_ids` and `item_ids` instead.
11
+ - `RemittanceCnab#charge_config_id` is DEPRECATED. Use `RemittanceCnab#config_id` instead.
12
+
5
13
  ## v0.23.0.beta1
6
14
 
7
15
  - Add PaymentConfig API suppport
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cobrato-client (0.23.0.beta1)
4
+ cobrato-client (0.23.0.beta2)
5
5
  multi_json (~> 1.11.2)
6
6
  typhoeus (~> 0.8.0)
7
7
  virtus (~> 1.0.5)
data/README.md CHANGED
@@ -50,38 +50,40 @@ client = Cobrato.client("YOUR_TOKEN_HERE")
50
50
 
51
51
  Now you have acess to every API endpoint:
52
52
 
53
- * [Payees API](http://docs.cobrato.com/#beneficiário)
54
- * [Bank Accounts API](http://docs.cobrato.com/#conta-bancária)
53
+ * [Payees API](http://docs.cobrato.com/#benefici-rio)
54
+ * [Bank Accounts API](http://docs.cobrato.com/#conta-banc-ria)
55
55
  * [Payers API](http://docs.cobrato.com/#pagador)
56
- * [Charge Configs API](http://docs.cobrato.com/#configuração-de-cobrança)
57
- * [Charges API](http://docs.cobrato.com/#cobrança)
56
+ * [Charge Configs API](http://docs.cobrato.com/#configura-o-de-cobran-a)
57
+ * [Charges API](http://docs.cobrato.com/#cobran-a)
58
58
  * [Regress Cnab](http://docs.cobrato.com/#cnab-de-retorno)
59
59
  * [Remittance Cnab](http://docs.cobrato.com/#cnab-de-remessa)
60
60
  * [CreditCards API](http://docs.cobrato.com/#cart-o-de-cr-dito)
61
61
  * [Webhooks API](http://docs.cobrato.com/#webhook)
62
+ * [Payment Config](http://docs.cobrato.com/#configura-o-de-pagamento) **(BETA)**
63
+ * [Payment](http://docs.cobrato.com/#pagamento) **(BETA)**
62
64
 
63
65
  ## Endpoints
64
66
 
65
- #### [Payees](http://docs.cobrato.com/#beneficiário)
67
+ #### [Payees](http://docs.cobrato.com/#benefici-rio)
66
68
 
67
69
  | HTTP method | Endpoint | Client method |
68
70
  | ----------- | ------------------------------------------------------------------------- | --------------------- |
69
- | POST | [api/v1/payees](http://docs.cobrato.com/#criação-de-beneficiário) | client.payees.create |
70
- | GET | [api/v1/payees](http://docs.cobrato.com/#lista-de-todos-os-beneficiários) | client.payees.list |
71
- | GET | [api/v1/payees/:id](http://docs.cobrato.com/#informações-do-beneficiário) | client.payees.show |
72
- | PUT | [api/v1/payees/:id](http://docs.cobrato.com/#atualização-de-beneficiário) | client.payees.update |
73
- | DELETE | [api/v1/payees/:id](http://docs.cobrato.com/#exclusão-de-beneficiário) | client.payees.destroy |
71
+ | POST | [api/v1/payees](http://docs.cobrato.com/#cria-o-de-benefici-rio) | client.payees.create |
72
+ | GET | [api/v1/payees](http://docs.cobrato.com/#lista-de-todos-os-benefici-rios) | client.payees.list |
73
+ | GET | [api/v1/payees/:id](http://docs.cobrato.com/#informa-es-do-benefici-rio) | client.payees.show |
74
+ | PUT | [api/v1/payees/:id](http://docs.cobrato.com/#atualiza-o-de-benefici-rio) | client.payees.update |
75
+ | DELETE | [api/v1/payees/:id](http://docs.cobrato.com/#exclus-o-de-benefici-rio) | client.payees.destroy |
74
76
 
75
- #### [Bank Accounts](http://docs.cobrato.com/#conta-bancária)
77
+ #### [Bank Accounts](http://docs.cobrato.com/#conta-banc-ria)
76
78
 
77
79
  | HTTP method | Endpoint | Client method |
78
80
  | ----------- | -------------------------------------------------------------------------------------- | ------------------------------------ |
79
- | POST | [api/v1/bank_accounts](http://docs.cobrato.com/#criação-de-conta-bancária) | client.bank_accounts.create |
80
- | GET | [api/v1/bank_accounts](http://docs.cobrato.com/#lista-de-todas-as-contas-bancárias) | client.bank_accounts.list |
81
- | GET | [api/v1/bank_accounts/:id](http://docs.cobrato.com/#informações-da-conta-bancária) | client.bank_accounts.show |
82
- | PUT | [api/v1/bank_accounts/:id](http://docs.cobrato.com/#atualização-de-conta-bancária) | client.bank_accounts.update |
83
- | DELETE | [api/v1/bank_accounts/:id](http://docs.cobrato.com/#exclusão-de-conta-bancária) | client.bank_accounts.destroy |
84
- | GET | [api/v1/bank_accounts/portfolio_codes](http://docs.cobrato.com/#carteiras-disponíveis) | client.bank_accounts.portfolio_codes |
81
+ | POST | [api/v1/bank_accounts](http://docs.cobrato.com/#cria-o-de-conta-banc-ria) | client.bank_accounts.create |
82
+ | GET | [api/v1/bank_accounts](http://docs.cobrato.com/#lista-de-todas-as-contas-banc-rias) | client.bank_accounts.list |
83
+ | GET | [api/v1/bank_accounts/:id](http://docs.cobrato.com/#informa-es-da-conta-banc-ria) | client.bank_accounts.show |
84
+ | PUT | [api/v1/bank_accounts/:id](http://docs.cobrato.com/#atualiza-o-de-conta-banc-ria) | client.bank_accounts.update |
85
+ | DELETE | [api/v1/bank_accounts/:id](http://docs.cobrato.com/#exclus-o-de-conta-banc-ria) | client.bank_accounts.destroy |
86
+ | GET | [api/v1/bank_accounts/portfolio_codes](http://docs.cobrato.com/#carteiras-dispon-veis) | client.bank_accounts.portfolio_codes |
85
87
 
86
88
  #### [Payers](http://docs.cobrato.com/#pagador)
87
89
 
@@ -92,51 +94,52 @@ Now you have acess to every API endpoint:
92
94
  | GET | [api/v1/payers/:id](http://docs.cobrato.com/#informa-es-do-pagador) | client.payers.show |
93
95
  | PUT | [api/v1/payers/:id](http://docs.cobrato.com/#atualiza-o-de-pagador) | client.payers.update |
94
96
 
95
- #### [Charge Configs](http://docs.cobrato.com/#configuração-de-cobrança)
97
+ #### [Charge Configs](http://docs.cobrato.com/#configura-o-de-cobran-a)
96
98
 
97
- | HTTP method | Endpoint | Client method |
98
- | ----------- | --------------------------------------------------------------------------------------------- | ------------------------------ |
99
- | POST | [api/v1/charge_configs](http://docs.cobrato.com/#criação-de-configuração-de-cobrança) | client.charge_configs.create |
100
- | GET | [api/v1/charge_configs](http://docs.cobrato.com/#lista-de-todas-as-configurações-de-cobrança) | client.charge_configs.list |
101
- | GET | [api/v1/charge_configs/:id](http://docs.cobrato.com/#informações-de-configuração-de-cobrança) | client.charge_configs.show |
102
- | PUT | [api/v1/charge_configs/:id](http://docs.cobrato.com/#atualização-de-configuração-de-cobrança) | client.charge_configs.update |
103
- | DELETE | [api/v1/charge_configs/:id](http://docs.cobrato.com/#exclusão-de-configuração-de-cobrança) | client.charge_configs.destroy |
99
+ | HTTP method | Endpoint | Client method |
100
+ | ----------- | -------------------------------------------------------------------------------------------- | ------------------------------ |
101
+ | POST | [api/v1/charge_configs](http://docs.cobrato.com/#cria-o-de-configura-o-de-cobran-a) | client.charge_configs.create |
102
+ | GET | [api/v1/charge_configs](http://docs.cobrato.com/#lista-de-todas-as-configura-es-de-cobran-a) | client.charge_configs.list |
103
+ | GET | [api/v1/charge_configs/:id](http://docs.cobrato.com/#informa-es-de-configura-o-de-cobran-a) | client.charge_configs.show |
104
+ | PUT | [api/v1/charge_configs/:id](http://docs.cobrato.com/#atualiza-o-de-configura-o-de-cobran-a) | client.charge_configs.update |
105
+ | DELETE | [api/v1/charge_configs/:id](http://docs.cobrato.com/#exclus-o-de-configura-o-de-cobran-a) | client.charge_configs.destroy |
104
106
 
105
- #### [Charges](http://docs.cobrato.com/#cobrança)
107
+ #### [Charges](http://docs.cobrato.com/#cobran-a)
106
108
 
107
109
  | HTTP method | Endpoint | Client method |
108
110
  | ----------- | -------------------------------------------------------------------------------------------- | ----------------------------- |
109
- | POST | [api/v1/charges](http://docs.cobrato.com/#criação-de-cobrança) | client.charges.create |
110
- | GET | [api/v1/charges](http://docs.cobrato.com/#lista-de-todas-as-cobrança) | client.charges.list |
111
- | GET | [api/v1/charges/:id](http://docs.cobrato.com/#informações-da-cobrança) | client.charges.show |
112
- | PUT | [api/v1/charges/:id](http://docs.cobrato.com/#atualização-de-cobrança) | client.charges.update |
113
- | DELETE | [api/v1/charges/:id](http://docs.cobrato.com/#exclusão-de-cobrança) | client.charges.destroy |
114
- | POST | [api/v1/charges/:id/receive](http://docs.cobrato.com/#recebimento-de-cobrança) | client.charges.receive |
115
- | POST | [api/v1/charges/:id/undo_receive](http://docs.cobrato.com/#desfazer-recebimento-de-cobrança) | client.charges.undo_receive |
116
- | POST | [api/v1/charges/:id/deliver_billet](http://docs.cobrato.com/#envio-de-boleto-da-cobrança) | client.charges.deliver_billet |
117
- | GET | [api/v1/charges/:id/billet](http://docs.cobrato.com/#boleto-da-cobrança) | client.charges.billet |
118
- | POST | [api/v1/charges/:id/cancel](http://docs.cobrato.com/#cancelar-cobrança) | client.charges.cancel |
111
+ | POST | [api/v1/charges](http://docs.cobrato.com/#cria-o-de-cobran-a) | client.charges.create |
112
+ | GET | [api/v1/charges](http://docs.cobrato.com/#lista-de-todas-as-cobran-a) | client.charges.list |
113
+ | GET | [api/v1/charges/:id](http://docs.cobrato.com/#informa-es-da-cobran-a) | client.charges.show |
114
+ | PUT | [api/v1/charges/:id](http://docs.cobrato.com/#atualiza-o-de-cobran-a) | client.charges.update |
115
+ | DELETE | [api/v1/charges/:id](http://docs.cobrato.com/#exclus-o-de-cobran-a) | client.charges.destroy |
116
+ | POST | [api/v1/charges/:id/receive](http://docs.cobrato.com/#recebimento-de-cobran-a) | client.charges.receive |
117
+ | POST | [api/v1/charges/:id/undo_receive](http://docs.cobrato.com/#desfazer-recebimento-de-cobran-a) | client.charges.undo_receive |
118
+ | POST | [api/v1/charges/:id/deliver_billet](http://docs.cobrato.com/#envio-de-boleto-da-cobran-a) | client.charges.deliver_billet |
119
+ | GET | [api/v1/charges/:id/billet](http://docs.cobrato.com/#boleto-da-cobran-a) | client.charges.billet |
120
+ | POST | [api/v1/charges/:id/cancel](http://docs.cobrato.com/#cancelar-cobran-a) | client.charges.cancel |
119
121
 
120
122
  #### [Regress Cnab](http://docs.cobrato.com/#cnab-de-retorno)
121
123
 
122
124
  | HTTP method | Endpoint | Client method |
123
125
  | ----------- | ------------------------------------------------------------------------------------ | ---------------------------- |
124
- | POST | [api/v1/regress_cnabs](http://docs.cobrato.com/#criação-de-cnab-de-retorno) | client.regress_cnabs.create |
126
+ | POST | [api/v1/regress_cnabs](http://docs.cobrato.com/#cria-o-de-cnab-de-retorno) | client.regress_cnabs.create |
125
127
  | GET | [api/v1/regress_cnabs](http://docs.cobrato.com/#lista-de-todas-as-cnabs-de-retorno) | client.regress_cnabs.list |
126
- | GET | [api/v1/regress_cnabs/:id](http://docs.cobrato.com/#informações-do-cnab-de-retorno) | client.regress_cnabs.show |
127
- | DELETE | [api/v1/regress_cnabs/:id](http://docs.cobrato.com/#exclusão-de-cnab-de-retorno) | client.regress_cnabs.destroy |
128
+ | GET | [api/v1/regress_cnabs/:id](http://docs.cobrato.com/#informa-es-do-cnab-de-retorno) | client.regress_cnabs.show |
129
+ | DELETE | [api/v1/regress_cnabs/:id](http://docs.cobrato.com/#exclus-o-de-cnab-de-retorno) | client.regress_cnabs.destroy |
128
130
  | GET | [api/v1/regress_cnabs/:id/file](http://docs.cobrato.com/#arquivo-do-cnab-de-retorno) | client.regress_cnabs.file |
129
131
 
130
132
  #### [Remittance Cnab](http://docs.cobrato.com/#cnab-de-remessa)
131
133
 
132
- | HTTP method | Endpoint | Client method |
133
- | ----------- | ---------------------------------------------------------------------------------------------------------------- | ------------------------------- |
134
- | POST | [api/v1/remittance_cnabs](http://docs.cobrato.com/##criação-de-arquivo-cnab-de-remessa) | client.remittance_cnabs.create |
135
- | GET | [api/v1/remittance_cnabs](http://docs.cobrato.com/#lista-de-todas-as-cnabs-de-remessa) | client.remittance_cnabs.list |
136
- | GET | [api/v1/remittance_cnabs/:id](http://docs.cobrato.com/#informações-do-cnab-de-remessa) | client.remittance_cnabs.show |
137
- | DELETE | [api/v1/remittance_cnabs/:id](http://docs.cobrato.com/#exclusão-de-cnab-de-remessa) | client.remittance_cnabs.destroy |
138
- | GET | [api/v1/remittance_cnabs/:id/file](http://docs.cobrato.com/#arquivo-do-cnab-de-remessa) | client.remittance_cnabs.file |
139
- | 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 |
134
+ | HTTP method | Endpoint | Client method |
135
+ | ----------- | ---------------------------------------------------------------------------------------------------------------- | -------------------------------------------- |
136
+ | POST | [api/v1/remittance_cnabs](http://docs.cobrato.com/cria-o-de-arquivo-cnab-de-remessa) | client.remittance_cnabs.create |
137
+ | GET | [api/v1/remittance_cnabs](http://docs.cobrato.com/#lista-de-todas-as-cnabs-de-remessa) | client.remittance_cnabs.list |
138
+ | GET | [api/v1/remittance_cnabs/:id](http://docs.cobrato.com/#informa-es-do-cnab-de-remessa) | client.remittance_cnabs.show |
139
+ | DELETE | [api/v1/remittance_cnabs/:id](http://docs.cobrato.com/#exclus-o-de-cnab-de-remessa) | client.remittance_cnabs.destroy |
140
+ | GET | [api/v1/remittance_cnabs/:id/file](http://docs.cobrato.com/#arquivo-do-cnab-de-remessa) | client.remittance_cnabs.file |
141
+ | 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 (DEPRECATED) |
142
+ | GET | [api/v1/remittance_cnabs/:id/items](http://docs.cobrato.com/#lista-de-todos-os-items-do-arquivo-de-remessa) | client.remittance_cnabs.items |
140
143
 
141
144
 
142
145
  #### [Credit Card](http://docs.cobrato.com/#cart-o-de-cr-dito)
@@ -152,17 +155,17 @@ Now you have acess to every API endpoint:
152
155
 
153
156
  | HTTP method | Endpoint | Client method |
154
157
  | ----------- | ---------------------------------------------------------------------- | ----------------------- |
155
- | POST | [api/v1/webhooks](http://docs.cobrato.com/#criação-de-webhook) | client.webhooks.create |
158
+ | POST | [api/v1/webhooks](http://docs.cobrato.com/#cria-o-de-webhook) | client.webhooks.create |
156
159
  | GET | [api/v1/webhooks](http://docs.cobrato.com/#lista-de-todos-os-webhooks) | client.webhooks.list |
157
- | GET | [api/v1/webhooks/:id](http://docs.cobrato.com/#informações-do-webhook) | client.webhooks.show |
158
- | PUT | [api/v1/webhooks/:id](http://docs.cobrato.com/#atualização-de-webhook) | client.webhooks.update |
159
- | DELETE | [api/v1/webhooks/:id](http://docs.cobrato.com/#exclusão-de-webhook) | client.webhooks.destroy |
160
+ | GET | [api/v1/webhooks/:id](http://docs.cobrato.com/#informa-es-do-webhook) | client.webhooks.show |
161
+ | PUT | [api/v1/webhooks/:id](http://docs.cobrato.com/#atualiza-o-de-webhook) | client.webhooks.update |
162
+ | DELETE | [api/v1/webhooks/:id](http://docs.cobrato.com/#exclus-o-de-webhook) | client.webhooks.destroy |
160
163
 
161
- #### [Charging types](http://docs.cobrato.com/#tipos-de-cobrança)
164
+ #### [Charging types](http://docs.cobrato.com/#tipos-de-cobran-a)
162
165
 
163
166
  | HTTP method | Endpoint | Client method |
164
167
  | ----------- | ------------------------------------------------------------------------------------- | -------------------------- |
165
- | GET | [api/v1/charging_types](http://docs.cobrato.com/#lista-de-todos-os-tipos-de-cobrança) | client.changing_types.list |
168
+ | GET | [api/v1/charging_types](http://docs.cobrato.com/#lista-de-todos-os-tipos-de-cobran-a) | client.changing_types.list |
166
169
 
167
170
  #### [Charge Template](http://docs.cobrato.com/#modelo-de-cobran-a)
168
171
 
@@ -184,6 +187,16 @@ Now you have acess to every API endpoint:
184
187
  | PUT | [api/v1/payment_configs/:id](http://docs.cobrato.com/#atualiza-o-de-configura-o-de-pagamento) | client.payment_configs.update |
185
188
  | DELETE | [api/v1/payment_configs/:id](http://docs.cobrato.com/#exclus-o-de-configura-o-de-pagamento) | client.payment_configs.destroy |
186
189
 
190
+ #### [Payment](http://docs.cobrato.com/#pagamento) **(BETA)**
191
+
192
+ | HTTP method | Endpoint | Client method |
193
+ | ----------- | ------------------------------------------------------------------------ | ----------------------- |
194
+ | POST | [api/v1/payments](http://docs.cobrato.com/#cria-o-de-pagamento) | client.payments.create |
195
+ | GET | [api/v1/payments](http://docs.cobrato.com/#lista-de-todos-os-pagamentos) | client.payments.list |
196
+ | GET | [api/v1/payments/:id](http://docs.cobrato.com/#informa-es-do-pagamento) | client.payments.show |
197
+ | PUT | [api/v1/payments/:id](http://docs.cobrato.com/#atualiza-o-de-pagamento) | client.payments.update |
198
+ | DELETE | [api/v1/payments/:id](http://docs.cobrato.com/#exclus-o-de-pagamento) | client.payments.destroy |
199
+
187
200
 
188
201
  ## Payload signature check
189
202
 
data/lib/cobrato.rb CHANGED
@@ -14,6 +14,7 @@ require "cobrato/entities/payer"
14
14
  require "cobrato/entities/bank_account"
15
15
  require "cobrato/entities/charge_config"
16
16
  require "cobrato/entities/payment_config"
17
+ require "cobrato/entities/payment"
17
18
  require "cobrato/entities/charge"
18
19
  require "cobrato/entities/webhook"
19
20
  require "cobrato/entities/bank_billet"
@@ -28,6 +29,7 @@ require "cobrato/resources/payer"
28
29
  require "cobrato/resources/bank_account"
29
30
  require "cobrato/resources/charge_config"
30
31
  require "cobrato/resources/payment_config"
32
+ require "cobrato/resources/payment"
31
33
  require "cobrato/resources/charge"
32
34
  require "cobrato/resources/webhook"
33
35
  require "cobrato/resources/charging_type"
@@ -31,6 +31,10 @@ module Cobrato
31
31
  Resources::PaymentConfig.new(http)
32
32
  end
33
33
 
34
+ def payments
35
+ Resources::Payment.new(http)
36
+ end
37
+
34
38
  def charges
35
39
  Resources::Charge.new(http)
36
40
  end
@@ -0,0 +1,23 @@
1
+ module Cobrato
2
+ module Entities
3
+ class Payment < Base
4
+ attribute :id, Integer
5
+ attribute :payment_config_id, Integer
6
+ attribute :amount, Decimal
7
+ attribute :date, Date
8
+ attribute :our_number, String
9
+ attribute :payment_method, String
10
+ attribute :payment_type, String
11
+ attribute :account, String
12
+ attribute :account_digit, String
13
+ attribute :agency, String
14
+ attribute :bank_code, String
15
+ attribute :payee_name, String
16
+ attribute :payee_document_type, String
17
+ attribute :payee_document, String
18
+ attribute :doc_goal, String
19
+ attribute :ted_goal, String
20
+ attribute :registration_status, String
21
+ end
22
+ end
23
+ end
@@ -2,8 +2,14 @@ module Cobrato
2
2
  module Entities
3
3
  class RemittanceCnab < Base
4
4
  attribute :id, Integer
5
- attribute :charge_config_id, Integer
5
+ attribute :charge_config_id, Integer # DEPRECATED
6
+ attribute :config_id, Integer
6
7
  attribute :status, String
8
+
9
+ def charge_config_id
10
+ puts "Warning: 'charge_config_id' is deprecated. Use 'config_id' instead."
11
+ super
12
+ end
7
13
  end
8
14
  end
9
15
  end
@@ -112,6 +112,12 @@ module Cobrato
112
112
  def underscore_pluralized(str)
113
113
  "#{str.gsub(/(.)([A-Z])/, '\1_\2').downcase}s"
114
114
  end
115
+
116
+ def deprecate(params, deprecated)
117
+ (params.keys.map(&:to_s) & deprecated).each do |a|
118
+ puts "Warning: The '#{a}' param is deprecated. See Cobrato API docs for more info."
119
+ end
120
+ end
115
121
  end
116
122
  end
117
123
  end
@@ -0,0 +1,7 @@
1
+ module Cobrato
2
+ module Resources
3
+ class Payment < Base
4
+ crud :all
5
+ end
6
+ end
7
+ end
@@ -6,6 +6,7 @@ module Cobrato
6
6
  crud :show, :list, :destroy
7
7
 
8
8
  def create(params)
9
+ deprecate(params, %w[charge_ids charge_config_ids])
9
10
  http.post(resource_base_path, { body: params }) do |response|
10
11
  respond_with_collection(response)
11
12
  end
@@ -18,11 +19,23 @@ module Cobrato
18
19
  end
19
20
 
20
21
  def charges(id)
22
+ puts "Warning: The 'charges' endpoint is deprecated. Use 'items' endpoint instead."
21
23
  http.get("#{resource_base_path}/#{id}/charges") do |response|
22
24
  respond_with_collection(response, 'Charge')
23
25
  end
24
26
  end
25
27
 
28
+ def items(id)
29
+ http.get("#{resource_base_path}/#{id}/items") do |response|
30
+ hash = parsed_body(response)
31
+ collection_name = hash.keys.first
32
+ class_name = collection_name.gsub(/(.)(.*)s/) { "#{$1.upcase}#{$2}" }
33
+ naked_klass = entity_klass(class_name)
34
+
35
+ hash[collection_name].map { |item| naked_klass.new(item) }
36
+ end
37
+ end
38
+
26
39
  end
27
40
  end
28
41
  end
@@ -1,3 +1,3 @@
1
1
  module Cobrato
2
- VERSION = '0.23.0.beta1'
2
+ VERSION = '0.23.0.beta2'
3
3
  end
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.23.0.beta1
4
+ version: 0.23.0.beta2
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: 2017-10-23 00:00:00.000000000 Z
13
+ date: 2017-12-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: typhoeus
@@ -203,6 +203,7 @@ files:
203
203
  - lib/cobrato/entities/credit_card.rb
204
204
  - lib/cobrato/entities/payee.rb
205
205
  - lib/cobrato/entities/payer.rb
206
+ - lib/cobrato/entities/payment.rb
206
207
  - lib/cobrato/entities/payment_config.rb
207
208
  - lib/cobrato/entities/regress_cnab.rb
208
209
  - lib/cobrato/entities/remittance_cnab.rb
@@ -220,6 +221,7 @@ files:
220
221
  - lib/cobrato/resources/hooks.rb
221
222
  - lib/cobrato/resources/payee.rb
222
223
  - lib/cobrato/resources/payer.rb
224
+ - lib/cobrato/resources/payment.rb
223
225
  - lib/cobrato/resources/payment_config.rb
224
226
  - lib/cobrato/resources/regress_cnab.rb
225
227
  - lib/cobrato/resources/remittance_cnab.rb