Class: Pluggy::Resources::MerchantSearch
- Inherits:
-
APIResource
- Object
- PluggyObject
- APIResource
- Pluggy::Resources::MerchantSearch
- Defined in:
- lib/pluggy/resources/merchant.rb
Overview
GET /merchants returns neither a list envelope nor a bare array, but three named buckets, so it gets its own type rather than being forced into the list interface.
Constant Summary
Constants inherited from PluggyObject
PluggyObject::ISO8601, PluggyObject::RESERVED, PluggyObject::TEMPORAL_KEYS
Instance Attribute Summary
Attributes inherited from PluggyObject
Instance Method Summary collapse
-
#[](key) ⇒ Object
Look up a resolved merchant by the CNPJ you asked for.
- #to_h_by_cnpj ⇒ Object
Methods inherited from PluggyObject
#==, #as_json, declared_fields, define_field, #each_pair, fields, #hash, #initialize, #inspect, #key?, #keys, #method_missing, nested, nested_types, #read, #respond_to_missing?, #to_h, #to_json, #values
Constructor Details
This class inherits a constructor from Pluggy::PluggyObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Pluggy::PluggyObject
Instance Method Details
#[](key) ⇒ Object
Look up a resolved merchant by the CNPJ you asked for.
22 23 24 25 26 |
# File 'lib/pluggy/resources/merchant.rb', line 22 def [](key) return super if key.is_a?(Symbol) || !key.to_s.match?(/\A\d{14}\z/) (found_merchants || []).find { |m| m["cnpj"] == key.to_s } end |
#to_h_by_cnpj ⇒ Object
28 29 30 |
# File 'lib/pluggy/resources/merchant.rb', line 28 def to_h_by_cnpj (found_merchants || []).to_h { |m| [m["cnpj"], m] } end |