zoop 0.1.0 → 0.2.1

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: 42c83c5481a3fb98de09d9c647a03498ad2e519f
4
- data.tar.gz: 29e96491cfa027b6c200052f653f71b67fd2f562
3
+ metadata.gz: c0d43cecfc529c6d5c8415703d52d20f0ec08b2e
4
+ data.tar.gz: 5d97b630e143cb35f8c13e973c0c8b37e0b0f5a9
5
5
  SHA512:
6
- metadata.gz: 005cb5236b80825602e80b57766c4533d2d9850e5f60e0e15af16db91b8a94c8388ffa5d73ab257d9d1dbc7760460c73c755ba44312fd67b53abcbc97a083df3
7
- data.tar.gz: f917e3867a804791aa68c7e45e55fd3386101b8232fc6a8ff2c7163634b4dac779f5042d8e5aa9a28919c7a1ffe6251233c3137ea706106c46224e11da5cff95
6
+ metadata.gz: b80a4ae0dd3e99f750c9e5a1e2456c9632e500eedf90f08dbed4249c1332f9fa3462dd858efb078d8720a0dda9459441f29f6b6bbf8c4562b4bcdcc375f2a106
7
+ data.tar.gz: dd34fda918d5a09b9d0aa6f419bc1567f8c79a9d217cc7c3aed5189b55893f08890d94d12326c37badf3e8f8e11a6e3f10652ac2c12026ba78bbb6a1e16f7770
data/lib/zoop.rb CHANGED
@@ -8,6 +8,7 @@ require_relative 'zoop/nested_model'
8
8
  require_relative 'zoop/errors'
9
9
  require_relative 'zoop/request'
10
10
  require_relative 'zoop/payment_method_common'
11
+ require_relative 'zoop/customer_common'
11
12
 
12
13
  Dir[File.expand_path('../zoop/resources/*.rb', __FILE__)].map do |path|
13
14
  require path
@@ -0,0 +1,21 @@
1
+ module Zoop
2
+ class CustomerCommon < Model
3
+
4
+ class << self
5
+
6
+ def find_by_document(document)
7
+ raise RequestError.new('Invalid CPF/CNPJ') unless document.present?
8
+
9
+ raw_document = document.scan(/[0-9]/).join
10
+ document_type = raw_document.size <= 11 ? :taxpayer_id : :ein
11
+
12
+ Zoop::Request.get(
13
+ url('search'),
14
+ headers: { 'Content-Type' => '' },
15
+ query: { document_type => raw_document }
16
+ ).call
17
+ end
18
+ end
19
+
20
+ end
21
+ end
@@ -1,4 +1,4 @@
1
1
  module Zoop
2
- class Buyer < Zoop::Model
2
+ class Buyer < Zoop::CustomerCommon
3
3
  end
4
4
  end
@@ -1,5 +1,5 @@
1
1
  module Zoop
2
- class Seller < Zoop::Model
2
+ class Seller < Zoop::CustomerCommon
3
3
 
4
4
  def create
5
5
  @custom_url = self.class.url(mount_url)
data/lib/zoop/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Zoop
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zoop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Mageste
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-13 00:00:00.000000000 Z
11
+ date: 2018-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -141,6 +141,7 @@ files:
141
141
  - bin/console
142
142
  - lib/zoop.rb
143
143
  - lib/zoop/core_ext.rb
144
+ - lib/zoop/customer_common.rb
144
145
  - lib/zoop/errors.rb
145
146
  - lib/zoop/model.rb
146
147
  - lib/zoop/nested_model.rb