Class: StarkInfra::PixDomain

Inherits:
StarkCore::Utils::SubResource
  • Object
show all
Defined in:
lib/pixdomain/pixdomain.rb

Overview

# PixDomain object

The PixDomain object displays the domain name and the QR Code domain certificate of Pix participants. All certificates must be registered with the Central Bank.

## Attributes (return-only):

  • certificates [list of PixDomain::Certificate objects]: certificate information of the Pix participant.

  • name [string]: current active domain (URL) of the Pix participant.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(certificates: nil, name: nil) ⇒ PixDomain

Returns a new instance of PixDomain.



19
20
21
22
# File 'lib/pixdomain/pixdomain.rb', line 19

def initialize(certificates: nil, name: nil)
  @certificates = certificates
  @name = name
end

Instance Attribute Details

#certificatesObject (readonly)

Returns the value of attribute certificates.



18
19
20
# File 'lib/pixdomain/pixdomain.rb', line 18

def certificates
  @certificates
end

#nameObject (readonly)

Returns the value of attribute name.



18
19
20
# File 'lib/pixdomain/pixdomain.rb', line 18

def name
  @name
end

Class Method Details

._parse_certificates(certificates) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/pixdomain/pixdomain.rb', line 37

def self._parse_certificates(certificates)
  certificate_maker = StarkInfra::Certificate.resource[:resource_maker]
  parsed_certificates = []
  certificates.each do |certificate|
    parsed_certificates << StarkCore::Utils::API.from_api_json(certificate_maker, certificate)
  end
  parsed_certificates
end

.query(user: nil) ⇒ Object

# Retrieve PixDomains

Receive a generator of PixDomain objects.

## Parameters (optional):

  • user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call

## Return:

  • generator of PixDomain objects with updated attributes



33
34
35
# File 'lib/pixdomain/pixdomain.rb', line 33

def self.query(user: nil)
  StarkInfra::Utils::Rest.get_stream(user: user, **resource)
end

.resourceObject



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/pixdomain/pixdomain.rb', line 46

def self.resource
  {
    resource_name: 'PixDomain',
    resource_maker: proc { |json|
      PixDomain.new(
        name: json['name'],
        certificates: _parse_certificates(json['certificates'])
      )
    }
  }
end