receitaws_client 0.0.8 → 0.0.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd6dbe3044a30479ea673693793faff945910e409940feff89cabdf5ee0f1286
4
- data.tar.gz: c91212031ffda78ea5e5068635b46824bd85795305eedf7aa426f5bed3689f7b
3
+ metadata.gz: f4faab0d0565ebfab3cb2efb385e9646041476607ee560050876ab807fe8fe68
4
+ data.tar.gz: 71a20fc8092f1a8871da86676186d6cfa0afd5a85adb5d8c981e86cad9b8862c
5
5
  SHA512:
6
- metadata.gz: 486277527023241e746bd85b891d060762a26e1926ff90971f2cb4b0cc7cd47988d6546e7cc7e052186e07b03b988ae377026f3565d46a7e9834ea8aaf35bdb4
7
- data.tar.gz: e46dc5d656effd878825b3844625fe99566d438ed9bfc06d926a5157a4874e9aaf33bb88a9309865b22b4f1ef9dabc9e46ed4ed188f903df60cc6424b2c0b42c
6
+ metadata.gz: f92d6816f181f5af063190e67e76c4669d8765c5f5e428bc0c6aee78bc9b950e635a99238ac238c1c5c0604b20b060923bd01795906436f2f95a1534e38735b5
7
+ data.tar.gz: f9640e1af0a266e9d5c8471826cd2f31226f7de8067aa86490b49eaff79eb638f37c82094786d4a343be32ffebe235b436e51360717bc66e2c7e0f22701311f7
data/README.md CHANGED
@@ -42,6 +42,11 @@ Receitaws.configure do |config|
42
42
  # plano - comenrcial ou gratis
43
43
  config.plano = 'gratis'
44
44
 
45
+ #
46
+ # dados mockados para development e testes
47
+ config.mock_test = true
48
+ config.mock_development = true
49
+
45
50
  end
46
51
  ```
47
52
 
@@ -20,6 +20,12 @@ module ReceitawsClient
20
20
  # Parâmetros iniciais
21
21
  PLANO = 'gratis'
22
22
 
23
+ # Mockar durante os desenvolvimento
24
+ MOCK_DEVELOPMENT = false
25
+
26
+ # Mockar durante os testes
27
+ MOCK_TEST = false
28
+
23
29
  # Endereço do WeService
24
30
  attr_writer :url
25
31
 
@@ -35,9 +41,15 @@ module ReceitawsClient
35
41
  # Obrigatório, numérico, Tempo de espera pela resposta do WeService em segundos
36
42
  attr_writer :timeout
37
43
 
38
- # Obrigatório, numérico, Tempo de espera pela resposta do WeService em segundos
44
+ # define o plano contratado
39
45
  attr_writer :plano
40
46
 
47
+ # mockar durenate o desenvolvimento
48
+ attr_writer :mock_development
49
+
50
+ # mockar durenate os teste
51
+ attr_writer :mock_test
52
+
41
53
  # Comando que recebe as configurações
42
54
  def configure
43
55
  yield self if block_given?
@@ -75,6 +87,16 @@ module ReceitawsClient
75
87
  @plano ||= PLANO
76
88
  end
77
89
 
90
+ # Definir mock
91
+ def mock_development
92
+ @mock_development ||= MOCK_DEVELOPMENT
93
+ end
94
+
95
+ # Definir mock
96
+ def mock_test
97
+ @mock_test ||= MOCK_TEST
98
+ end
99
+
78
100
  # Definir url que será utilizado
79
101
  def base_uri
80
102
  "#{url_receitaws}/#{api_version}"
@@ -6,6 +6,10 @@ module ReceitawsClient
6
6
  # cnpj: obrigatório, numérico, o CNPJ a ser pesquisado
7
7
  # Retonar um obejto do tipo Receitaws::Cnpj
8
8
  def self.executar(cnpj)
9
+ if (Rails.env.development? && ReceitawsClient.mock_development) || (Rails.env.test? && ReceitawsClient.mock_test)
10
+ return ReceitawsClient::Mock::ConsultarCnpj.executar cnpj
11
+ end
12
+
9
13
  Rails.logger.tagged 'ReceitawsClient' do
10
14
  cnpj = cnpj.to_s.gsub(/[^0-9A-Za-z]/, '')
11
15
  unless ReceitawsClient::Cnpj.valida_digito_cnpj(cnpj)
@@ -4,7 +4,7 @@ module ReceitawsClient
4
4
  module Version
5
5
  MAJOR = 0
6
6
  MINOR = 0
7
- PATCH = 8
7
+ PATCH = 9
8
8
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: receitaws_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Isaac Guerra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-03 00:00:00.000000000 Z
11
+ date: 2021-11-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Client Rails não oficial do Webservice da ReceitaWS - https://receitaws.com.br/
14
14
  email: