Class: Zoop::CustomerCommon
- Inherits:
-
Model
- Object
- ZoopObject
- Model
- Zoop::CustomerCommon
- Defined in:
- lib/zoop/customer_common.rb
Constant Summary
Constants inherited from ZoopObject
Instance Attribute Summary
Attributes inherited from ZoopObject
Class Method Summary collapse
Methods inherited from Model
class_name, #create, create, #destroy, find_by_id, #save, underscored_class_name, #update, url, #url
Methods inherited from ZoopObject
#==, #[]=, convert, #empty?, #initialize, #respond_to?, #to_hash, #to_s, #unsaved_attributes
Constructor Details
This class inherits a constructor from Zoop::ZoopObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Zoop::ZoopObject
Class Method Details
.find_by_document(document) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/zoop/customer_common.rb', line 6 def find_by_document(document) raise RequestError.new('Invalid CPF/CNPJ') unless document.present? raw_document = document.scan(/[0-9]/).join document_type = raw_document.size <= 11 ? :taxpayer_id : :ein Zoop::Request.get( url('search'), headers: { 'Content-Type' => '' }, query: { document_type => raw_document } ).call end |