Class: GenesisRuby::Api::Requests::NonFinancial::Payee::AssociatePayeeWithOwners

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

Overview

Associate Owners with a specific Payee.

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) ⇒ AssociatePayeeWithOwners

Associate Payee With Owners initialization



14
15
16
17
18
# File 'lib/genesis_ruby/api/requests/non_financial/payee/associate_payee_with_owners.rb', line 14

def initialize(configuration, _builder_interface = nil)
  super configuration

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

Instance Attribute Details

#payee_unique_idObject

Returns the value of attribute payee_unique_id.



11
12
13
# File 'lib/genesis_ruby/api/requests/non_financial/payee/associate_payee_with_owners.rb', line 11

def payee_unique_id
  @payee_unique_id
end

Instance Method Details

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

Add a single owner to the owners collection



21
22
23
24
25
26
27
28
# File 'lib/genesis_ruby/api/requests/non_financial/payee/associate_payee_with_owners.rb', line 21

def add_owner(unique_id:, **options)
  raise GenesisRuby::InvalidArgumentError, 'Owner unique_id must be a String' unless unique_id.is_a?(String)
  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



31
32
33
34
35
36
37
38
39
40
# File 'lib/genesis_ruby/api/requests/non_financial/payee/associate_payee_with_owners.rb', line 31

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