Class: GenesisRuby::Api::Requests::NonFinancial::Payee::Owners::AssociateOwnerWithOwners

Inherits:
Base::NonFinancial::Payee::Base show all
Defined in:
lib/genesis_ruby/api/requests/non_financial/payee/owners/associate_owner_with_owners.rb

Overview

Associate Owners with a specific Owner.

Constant Summary

Constants inherited from GenesisRuby::Api::Request

GenesisRuby::Api::Request::AUTH_TYPE_BASIC, GenesisRuby::Api::Request::AUTH_TYPE_TOKEN, GenesisRuby::Api::Request::METHOD_DELETE, GenesisRuby::Api::Request::METHOD_GET, GenesisRuby::Api::Request::METHOD_PATCH, GenesisRuby::Api::Request::METHOD_POST, GenesisRuby::Api::Request::METHOD_PUT, GenesisRuby::Api::Request::PORT_HTTPS, GenesisRuby::Api::Request::PROTOCOL_HTTPS

Instance Attribute Summary collapse

Attributes inherited from GenesisRuby::Api::Request

#api_config

Instance Method Summary collapse

Methods inherited from GenesisRuby::Api::Request

#build_document

Constructor Details

#initialize(configuration, _builder_interface = nil) ⇒ AssociateOwnerWithOwners

Associate Owner With Owners initialization



15
16
17
18
19
# File 'lib/genesis_ruby/api/requests/non_financial/payee/owners/associate_owner_with_owners.rb', line 15

def initialize(configuration, _builder_interface = nil)
  super configuration

  self.request_path = 'payee/owners/:owner_unique_id/owners'
end

Instance Attribute Details

#owner_unique_idObject

Returns the value of attribute owner_unique_id.



12
13
14
# File 'lib/genesis_ruby/api/requests/non_financial/payee/owners/associate_owner_with_owners.rb', line 12

def owner_unique_id
  @owner_unique_id
end

Instance Method Details

#add_owner(unique_id:, **options) ⇒ Object

Add a single owner to the owners collection



22
23
24
25
26
27
28
29
30
31
# File 'lib/genesis_ruby/api/requests/non_financial/payee/owners/associate_owner_with_owners.rb', line 22

def add_owner(unique_id:, **options)
  unless unique_id.is_a?(String)
    raise GenesisRuby::InvalidArgumentError, 'Owner unique_id must be a String'
  end
  raise GenesisRuby::InvalidArgumentError, 'Owner unique_id is required' if unique_id.empty?

  validate_percent_ownership(options[:percent_ownership]) if options.key?(:percent_ownership)

  owners << { unique_id: unique_id }.merge(options)
end

#owners=(value) ⇒ Object

Assign owners collection with validation



34
35
36
37
38
39
40
41
42
43
# File 'lib/genesis_ruby/api/requests/non_financial/payee/owners/associate_owner_with_owners.rb', line 34

def owners=(value)
  if value.nil?
    @owners = nil
  elsif !value.is_a?(Array)
    raise GenesisRuby::InvalidArgumentError, 'Owners must be an Array'
  else
    validate_owners_collection(value)
    @owners = value
  end
end