boletosimples 0.0.7 → 0.1.1

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.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1 -1
  3. data/README.md +156 -3
  4. data/boletosimples.gemspec +9 -9
  5. data/lib/boletosimples.rb +38 -4
  6. data/lib/boletosimples/configuration.rb +69 -0
  7. data/lib/boletosimples/extra.rb +8 -0
  8. data/lib/boletosimples/last_request.rb +43 -0
  9. data/lib/boletosimples/middlewares/last_request.rb +9 -0
  10. data/lib/boletosimples/middlewares/raise_error.rb +11 -0
  11. data/lib/boletosimples/middlewares/user_agent.rb +10 -0
  12. data/lib/boletosimples/resources/bank_billet.rb +13 -0
  13. data/lib/boletosimples/resources/base_model.rb +8 -0
  14. data/lib/boletosimples/resources/customer.rb +4 -0
  15. data/lib/boletosimples/resources/partner/user.rb +7 -0
  16. data/lib/boletosimples/resources/transaction.rb +4 -0
  17. data/lib/boletosimples/response_error.rb +43 -0
  18. data/lib/boletosimples/version.rb +1 -1
  19. data/spec/boletosimples/configuration_spec.rb +84 -0
  20. data/spec/boletosimples/extra_spec.rb +31 -0
  21. data/spec/boletosimples/last_request_spec.rb +34 -0
  22. data/spec/boletosimples/resources/bank_billet_spec.rb +75 -0
  23. data/spec/boletosimples/resources/customer_spec.rb +66 -0
  24. data/spec/boletosimples/resources/partner/user_spec.rb +19 -0
  25. data/spec/boletosimples/resources/transactions_spec.rb +17 -0
  26. data/spec/fixtures/vcr_cassettes/configuration/client_credentials/invalid.yml +64 -0
  27. data/spec/fixtures/vcr_cassettes/configuration/client_credentials/valid.yml +56 -0
  28. data/spec/fixtures/vcr_cassettes/extra/userinfo/authenticated.yml +58 -0
  29. data/spec/fixtures/vcr_cassettes/extra/userinfo/not_authenticated.yml +54 -0
  30. data/spec/fixtures/vcr_cassettes/last_request/bank_billets.yml +129 -0
  31. data/spec/fixtures/vcr_cassettes/last_request/userinfo.yml +58 -0
  32. data/spec/fixtures/vcr_cassettes/resources/bank_billet/all.yml +132 -0
  33. data/spec/fixtures/vcr_cassettes/resources/bank_billet/cancel.yml +125 -0
  34. data/spec/fixtures/vcr_cassettes/resources/bank_billet/create/invalid_params.yml +61 -0
  35. data/spec/fixtures/vcr_cassettes/{BoletoSimples_Client/_cancel_bank_billet/already_canceled.yml → resources/bank_billet/create/invalid_root.yml} +24 -24
  36. data/spec/fixtures/vcr_cassettes/{BoletoSimples_Client/_create_bank_billet/with_valid_data.yml → resources/bank_billet/create/valid.yml} +32 -28
  37. data/spec/fixtures/vcr_cassettes/{BoletoSimples_Client/_bank_billet/existing_bank_billet.yml → resources/bank_billet/find.yml} +30 -28
  38. data/spec/fixtures/vcr_cassettes/resources/customer/all.yml +72 -0
  39. data/spec/fixtures/vcr_cassettes/resources/customer/create/invalid_params.yml +59 -0
  40. data/spec/fixtures/vcr_cassettes/resources/customer/create/invalid_root.yml +58 -0
  41. data/spec/fixtures/vcr_cassettes/{BoletoSimples_Client/_create_customer/with_valid_data.yml → resources/customer/create/valid.yml} +30 -26
  42. data/spec/fixtures/vcr_cassettes/resources/customer/find.yml +59 -0
  43. data/spec/fixtures/vcr_cassettes/resources/partner/user/create.yml +60 -0
  44. data/spec/fixtures/vcr_cassettes/resources/transaction/all.yml +62 -0
  45. data/spec/spec_helper.rb +10 -0
  46. data/spec/support/vcr.rb +8 -0
  47. metadata +97 -80
  48. data/example/access_token_example.rb +0 -79
  49. data/example/oauth_example.rb +0 -126
  50. data/lib/boletosimples/client.rb +0 -100
  51. data/lib/boletosimples/oauth_client.rb +0 -74
  52. data/spec/boletosimples/client_spec.rb +0 -415
  53. data/spec/boletosimples/oauth_client_spec.rb +0 -17
  54. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_bank_billet/not_found.yml +0 -44
  55. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_bank_billets.yml +0 -63
  56. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_cancel_bank_billet/with_invalid_bank_billet.yml +0 -54
  57. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_cancel_bank_billet/with_valid_bank_billet.yml +0 -71
  58. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_create_bank_billet/with_invalid_data.yml +0 -64
  59. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_create_customer/with_invalid_data.yml +0 -59
  60. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_customer/existing_customer.yml +0 -57
  61. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_customer/not_found.yml +0 -58
  62. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_customers.yml +0 -59
  63. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_transactions.yml +0 -67
  64. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_userinfo/with_authentication.yml +0 -56
  65. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_userinfo/with_authentication/.yml +0 -56
  66. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_userinfo/without_authentication.yml +0 -54
  67. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_userinfo/without_authentication/.yml +0 -54
  68. data/spec/fixtures/vcr_cassettes/BoletoSimples_OAuthClient/_userinfo/without_authentication/.yml +0 -62
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 544af5de32ea938f99ed648486d828b9414115f8
4
- data.tar.gz: 29b5b8c262fa0e1e5c21db89a907ed2e390d4327
3
+ metadata.gz: 948e6f3aa087ac1903c87f91160c0f93e225dcea
4
+ data.tar.gz: 935cd49f3e6963721f5b02822441ee5921a83f7d
5
5
  SHA512:
6
- metadata.gz: bf70373d7671b92546e502195f903db5206d578ecf715c6d9258ea5ba81c2a5af759e43dcb24694c83740d526d2dd20fbd6ce1ecc6f4256e3b60a46c9123cbbb
7
- data.tar.gz: de8e4b256b7407fd4fd0ed4661ab1d45253117227fbb881090ceb483797531af97b596c18cd1b647677d4cd920d6e4fb0b9fc664e2140cf5331e74523453fdd6
6
+ metadata.gz: a512a53c11957d7d8392da1ee15bc86ebe1253bf85d3ff010fbf8f05a14aeda732eabd69fd087b052f57ae98a0bf4dd0da830b2465f51d1f215b15e20019f919
7
+ data.tar.gz: 9df50c21b21b7a952816772b93ce48febe8128b81e922643743b676732dff346ba5f2a1ffe30525b53a79710b62a99b0469099eae342f3df9f07213697b0f595
data/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Changelog
2
2
 
3
- ## 0.0.7 (unreleased)
3
+ ## 0.1.1 (unreleased)
4
4
 
5
5
  ### features
6
6
 
data/README.md CHANGED
@@ -14,8 +14,6 @@
14
14
 
15
15
  Esta gem inclui todos os métodos disponíveis na [Boleto Simples JSON API](http://api.boletosimples.com.br).
16
16
 
17
- Ela suporta Basic Auth e OAuth 2.0 para ações realizadas por parceiros.
18
-
19
17
  ## Instalação
20
18
 
21
19
  Adicione a linha a baixo no seu Gemfile:
@@ -30,9 +28,164 @@ Ou instale você mesmo:
30
28
 
31
29
  $ gem install boletosimples
32
30
 
31
+ ## Configuração
32
+
33
+ ```ruby
34
+ require 'boletosimples'
35
+
36
+ BoletoSimples.configure do |c|
37
+ c.environment = :production # defaut :sandbox
38
+ c.access_token = 'access-token'
39
+ end
40
+ ```
41
+
42
+ ### Variáveis de ambiente
43
+
44
+ Você também pode configurar as variáveis de ambiente a seguir e não será necessário chamar `BoletoSimples.configure`
45
+
46
+ ```bash
47
+ ENV['BOLETOSIMPLES_ENV']
48
+ ENV['BOLETOSIMPLES_APP_ID']
49
+ ENV['BOLETOSIMPLES_APP_SECRET']
50
+ ENV['BOLETOSIMPLES_ACCESS_TOKEN']
51
+ ```
52
+
53
+ ### Configurando cache
54
+
55
+ É altamente recomendável utilizar o cache para evitar chegar no [limite de requisições](http://api.boletosimples.com.br/#limite-de-requisicoes)
56
+
57
+ Para isso recomendamos a utilização da gem [Dalli](https://github.com/mperham/dalli)
58
+
59
+ Exemplo:
60
+
61
+ ```ruby
62
+ require 'dalli'
63
+
64
+ BoletoSimples.configure do |c|
65
+ c.cache = ActiveSupport::Cache.lookup_store(:dalli_store, ['localhost:11211'], namespace: 'boletosimples_client', compress: true)
66
+ end
67
+ ```
68
+
33
69
  ## Exemplos
34
70
 
35
- Veja a [lista de métodos aqui](https://github.com/boletosimples/boletosimples-ruby/blob/master/example)
71
+ ### Boletos Bancários
72
+
73
+ ```ruby
74
+ # Criar um boleto
75
+ @bank_billet = BoletoSimples::BankBillet.create({
76
+ amount: 9.01,
77
+ description: 'Despesas do contrato 0012',
78
+ expire_at: '2014-01-01',
79
+ customer_address: 'Rua quinhentos',
80
+ customer_address_complement: 'Sala 4',
81
+ customer_address_number: '111',
82
+ customer_city_name: 'Rio de Janeiro',
83
+ customer_cnpj_cpf: '012.345.678-90',
84
+ customer_email: 'cliente@bom.com',
85
+ customer_neighborhood: 'Sao Francisco',
86
+ customer_person_name: 'Joao da Silva',
87
+ customer_person_type: 'individual',
88
+ customer_phone_number: '2112123434',
89
+ customer_state: 'RJ',
90
+ customer_zipcode: '12312-123',
91
+ notification_url: 'http://example.com.br/notify'
92
+ })
93
+
94
+ # Criar um novo boleto instanciando o objeto
95
+ @bank_billet = BoletoSimples::BankBillet.new(amount: 199.99, expire_at: '2020-01-01')
96
+ @bank_billet.description = 'Cobrança XPTO'
97
+ @bank_billet.save
98
+
99
+ # Mensagens de erro na criação do boleto
100
+ @bank_billet = BoletoSimples::BankBillet.create(amount: 199.99)
101
+ @bank_billet.response_errors
102
+ # {:expire_at=>["não pode ficar em branco", "não é uma data válida"], :customer_person_name=>["não pode ficar em branco"], :customer_cnpj_cpf=>["não pode ficar em branco", "não é um CPNJ ou CPF válido"], :description=>["não pode ficar em branco"], :customer_zipcode=>["não pode ficar em branco"]
103
+
104
+ # Pegar informações de um boleto
105
+ @bank_billet = BoletoSimples::BankBillet.find(1) # onde 1 é o id do boleto.
106
+
107
+ # Se o não for encontrado nenhum boleto com o id informado, uma exceção será levantada com a mensagem:
108
+ # Couldn't find BankBillet with 'id'=1
109
+
110
+ # Listar os boletos
111
+ @bank_billets = BoletoSimples::BankBillet.all(page: 1, per_page: 50)
112
+ @bank_billet.each do |bank_billet|
113
+ puts bank_billet.id
114
+ end
115
+
116
+ # Após realizar a chamada na listagem, você terá acesso aos seguintes dados:
117
+
118
+ BoletoSimples.last_request.total # número total de boletos
119
+ BoletoSimples.last_request.links[:first] # url da primeira página
120
+ BoletoSimples.last_request.links[:prev] # url da página anterior
121
+ BoletoSimples.last_request.links[:next] # url da próxima página
122
+ BoletoSimples.last_request.links[:last] # url da última página
123
+
124
+ # Cancelar um boleto
125
+ @bank_billet = BoletoSimples::BankBillet.find(1)
126
+ @bank_billet.cancel
127
+
128
+ ```
129
+
130
+ ### Clientes
131
+
132
+ ```ruby
133
+ # Criar um cliente
134
+ @customer = BoletoSimples::Customer.create({
135
+ person_name: "Joao da Silva",
136
+ cnpj_cpf: "012.345.678-90",
137
+ email: "cliente@bom.com",
138
+ address: "Rua quinhentos",
139
+ city_name: "Rio de Janeiro",
140
+ state: "RJ",
141
+ neighborhood: "bairro",
142
+ zipcode: "12312-123",
143
+ address_number: "111",
144
+ address_complement: "Sala 4",
145
+ phone_number: "2112123434"
146
+ })
147
+
148
+ # Mensagens de erro na criação do cliente
149
+ @customer = BoletoSimples::Customer.new(person_name: '')
150
+ @customer.response_errors
151
+ # {:person_name=>["não pode ficar em branco"], :cnpj_cpf=>["não pode ficar em branco"], :zipcode=>["não pode ficar em branco"]}
152
+
153
+ # Listar os clientes
154
+ @customers = BoletoSimples::Customer.all(page: 1, per_page: 50)
155
+ @customers.each do |customer|
156
+ puts customer.id
157
+ end
158
+
159
+ # Após realizar a chamada na listagem, você terá acesso aos seguintes dados:
160
+
161
+ BoletoSimples.last_request.total # número total de clientes
162
+ BoletoSimples.last_request.links[:first] # url da primeira página
163
+ BoletoSimples.last_request.links[:prev] # url da página anterior
164
+ BoletoSimples.last_request.links[:next] # url da próxima página
165
+ BoletoSimples.last_request.links[:last] # url da última página
166
+
167
+ # Atualizar um cliente
168
+ @customer = BoletoSimples::Customer.find(1)
169
+ @customer.person_name = 'Novo nome'
170
+ @customer.save
171
+ ```
172
+
173
+ ### Extrato
174
+
175
+ ```ruby
176
+ # Listar todas as transações
177
+ @transactions = BoletoSimples::Transaction.all
178
+ @transactions.each do |transaction|
179
+ puts transaction.id
180
+ end
181
+ ```
182
+
183
+ ### Extras
184
+
185
+ ```ruby
186
+ # Dados do usuário logado
187
+ @userinfo = BoletoSimples::Extra.userinfo
188
+ ```
36
189
 
37
190
  ## OAuth 2.0 Authentication (para acessar as contas dos usuários)
38
191
 
@@ -21,16 +21,16 @@ Gem::Specification.new do |gem|
21
21
  gem.required_ruby_version = '>= 1.9'
22
22
 
23
23
  # Gems that must be intalled for boletosimples to work
24
- gem.add_dependency 'httparty', '~> 0.13.1'
25
- gem.add_dependency 'multi_json', '~> 1.10.1'
26
- gem.add_dependency 'oauth2', '~> 1.0.0'
24
+ gem.add_dependency 'her', '~> 0.7.3'
25
+ gem.add_dependency 'faraday_middleware', '~> 0.9.1'
26
+ gem.add_dependency 'faraday-http-cache', '~> 1.0.1'
27
27
 
28
28
  # Gems that must be installed for boletosimples to compile and build
29
- gem.add_development_dependency 'pry'
30
- gem.add_development_dependency 'rspec', '~> 3.1'
29
+ gem.add_development_dependency 'pry', '~> 0.10.1'
30
+ gem.add_development_dependency 'rspec', '~> 3.2.0'
31
31
  gem.add_development_dependency 'vcr', '~> 2.9'
32
- gem.add_development_dependency 'webmock'
33
- gem.add_development_dependency 'rake'
34
- gem.add_development_dependency 'coveralls'
35
- gem.add_development_dependency 'codeclimate-test-reporter'
32
+ gem.add_development_dependency 'webmock', '~> 1.20.4'
33
+ gem.add_development_dependency 'rake', '~> 10.4.2'
34
+ gem.add_development_dependency 'coveralls', '~> 0.7.11'
35
+ gem.add_development_dependency 'codeclimate-test-reporter', '~> 0.4.7'
36
36
  end
data/lib/boletosimples.rb CHANGED
@@ -1,5 +1,39 @@
1
- require 'json'
1
+ require 'her'
2
+ require 'faraday_middleware'
3
+ require 'faraday-http-cache'
2
4
  require 'boletosimples/version'
3
- require 'boletosimples/client'
4
- require 'boletosimples/oauth_client'
5
- require 'oauth2_patch'
5
+
6
+ module BoletoSimples
7
+ autoload :Configuration, 'boletosimples/configuration'
8
+ autoload :Extra, 'boletosimples/extra'
9
+ autoload :ResponseError, 'boletosimples/response_error'
10
+ autoload :LastRequest, 'boletosimples/last_request'
11
+
12
+ autoload :BankBillet, 'boletosimples/resources/bank_billet'
13
+ autoload :Customer, 'boletosimples/resources/customer'
14
+ autoload :Transaction, 'boletosimples/resources/transaction'
15
+ autoload :BaseModel, 'boletosimples/resources/base_model'
16
+
17
+ module Partner
18
+ autoload :User, 'boletosimples/resources/partner/user'
19
+ end
20
+
21
+ module Middleware
22
+ autoload :UserAgent, 'boletosimples/middlewares/user_agent'
23
+ autoload :RaiseError, 'boletosimples/middlewares/raise_error'
24
+ autoload :LastRequest, 'boletosimples/middlewares/last_request'
25
+ end
26
+
27
+ class << self
28
+ attr_accessor :configuration, :last_request
29
+
30
+ def configure
31
+ @configuration = Configuration.new
32
+ yield(configuration) if block_given?
33
+ configuration.setup_her # after changing configuration gem her should be configured
34
+ end
35
+ end
36
+
37
+ end
38
+
39
+ BoletoSimples.configure
@@ -0,0 +1,69 @@
1
+ # encoding: utf-8
2
+ module BoletoSimples
3
+
4
+ class Configuration
5
+ attr_accessor :environment, :application_id, :application_secret, :access_token, :cache
6
+
7
+
8
+ BASE_URI = {
9
+ sandbox: 'https://sandbox.boletosimples.com.br/api/v1',
10
+ production: 'https://boletosimples.com.br/api/v1'
11
+ }
12
+
13
+ def initialize
14
+ @environment = (ENV['BOLETOSIMPLES_ENV'] || :sandbox).to_sym
15
+ @application_id = ENV['BOLETOSIMPLES_APP_ID']
16
+ @application_secret = ENV['BOLETOSIMPLES_APP_SECRET']
17
+ @access_token = ENV['BOLETOSIMPLES_ACCESS_TOKEN']
18
+ @cache = nil
19
+ end
20
+
21
+ def base_uri
22
+ BASE_URI[@environment]
23
+ end
24
+
25
+ def user_agent
26
+ "BoletoSimples Ruby Client v#{BoletoSimples::VERSION} (contato@boletosimples.com.br)"
27
+ end
28
+
29
+ def access_token?
30
+ !@access_token.nil?
31
+ end
32
+
33
+ def client_credentials
34
+ response = Her::API.default_api.connection.post 'oauth2/token', {
35
+ grant_type: 'client_credentials',
36
+ client_id: application_id,
37
+ client_secret: application_secret
38
+ }
39
+ response.body[:data]
40
+ end
41
+
42
+ def setup_her
43
+ Her::API.setup url: BoletoSimples.configuration.base_uri do |c|
44
+ # Request
45
+ c.use BoletoSimples::Middleware::UserAgent
46
+ c.use FaradayMiddleware::OAuth2, BoletoSimples.configuration.access_token if BoletoSimples.configuration.access_token?
47
+ c.use FaradayMiddleware::EncodeJson
48
+ if !BoletoSimples.configuration.cache.nil?
49
+ c.use Faraday::HttpCache, store: BoletoSimples.configuration.cache
50
+ end
51
+
52
+ # Response
53
+ c.use BoletoSimples::Middleware::LastRequest
54
+ c.use BoletoSimples::Middleware::RaiseError
55
+ c.use Her::Middleware::DefaultParseJSON
56
+
57
+ # Adapter
58
+ c.use Faraday::Adapter::NetHttp
59
+ end
60
+
61
+ # Because Her set the api on the moment module is included we need to call use_api again, after changing the configuration.
62
+ [BankBillet, Customer, Transaction, Partner::User].each do |klass|
63
+ klass.send(:use_api, Her::API.default_api)
64
+ end
65
+ end
66
+
67
+ end
68
+
69
+ end
@@ -0,0 +1,8 @@
1
+ module BoletoSimples
2
+ class Extra
3
+ def self.userinfo
4
+ response = Her::API.default_api.connection.get '/api/v1/userinfo.json'
5
+ response.body[:data]
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,43 @@
1
+ module BoletoSimples
2
+ class LastRequest
3
+ attr_reader :body, :response_headers, :total, :ratelimit_limit, :ratelimit_remaining, :links
4
+
5
+ def initialize(env)
6
+ @env = env
7
+ end
8
+
9
+ def body
10
+ @body ||= @env[:body][:data]
11
+ end
12
+
13
+ def response_headers
14
+ @response_headers ||= @env[:response_headers]
15
+ end
16
+
17
+ def total
18
+ @total ||= @env[:response_headers]["total"].to_i
19
+ end
20
+
21
+ def ratelimit_limit
22
+ ratelimit_limit ||= @env[:response_headers]["x-ratelimit-limit"].to_i
23
+ end
24
+
25
+ def ratelimit_remaining
26
+ @ratelimit_remaining ||= @env[:response_headers]["x-ratelimit-remaining"].to_i
27
+ end
28
+
29
+ def links
30
+ return @links unless @links.nil?
31
+ link_header = @env[:response_headers]["link"]
32
+ return {} if link_header.nil?
33
+ @links = {}
34
+ link_header.split(", ").each do |link|
35
+ key = /rel=\"(.*)\"/.match(link)[1]
36
+ value = /\<(.*)\>/.match(link)[1]
37
+ @links[key] = value
38
+ end
39
+ @links.symbolize_keys!
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,9 @@
1
+ module BoletoSimples
2
+ module Middleware
3
+ class LastRequest < Faraday::Response::Middleware
4
+ def on_complete(env)
5
+ BoletoSimples.last_request = BoletoSimples::LastRequest.new(env)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ module BoletoSimples
2
+ module Middleware
3
+ class RaiseError < Faraday::Response::Middleware
4
+ def on_complete(env)
5
+ status = env[:status].to_i
6
+ klass = BoletoSimples::ResponseError
7
+ raise klass.new(env) if (400..599).include?(status) and env[:body][:data][:error]
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,10 @@
1
+ module BoletoSimples
2
+ module Middleware
3
+ class UserAgent < Faraday::Middleware
4
+ def call(env)
5
+ env[:request_headers]["User-Agent"] = BoletoSimples.configuration.user_agent
6
+ @app.call(env)
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ module BoletoSimples
2
+ class BankBillet < BaseModel
3
+
4
+ def cancel
5
+ self.class.request(:_method => :put, :_path => self.class.build_request_path('bank_billets/:id/cancel', {self.class.primary_key => id})) do |parsed_data, response|
6
+ assign_attributes(self.class.parse(parsed_data[:data])) if parsed_data[:data].any?
7
+ @metadata = parsed_data[:metadata]
8
+ @response_errors = parsed_data[:errors]
9
+ end
10
+ self
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+ module BoletoSimples
2
+ class BaseModel
3
+ include Her::Model
4
+
5
+ parse_root_in_json true
6
+ include_root_in_json true
7
+ end
8
+ end