Class: XeroKiwi::Accounting::ExternalLink

Inherits:
Object
  • Object
show all
Defined in:
lib/xero_kiwi/accounting/external_link.rb

Overview

A Xero external link (social/web profile). Used by Organisation.

See: developer.xero.com/documentation/api/accounting/types#externallinks

Constant Summary collapse

ATTRIBUTES =
{
  link_type: "LinkType",
  url:       "Url"
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ ExternalLink

Returns a new instance of ExternalLink.



16
17
18
19
20
# File 'lib/xero_kiwi/accounting/external_link.rb', line 16

def initialize(attrs)
  attrs      = attrs.transform_keys(&:to_s)
  @link_type = attrs["LinkType"]
  @url       = attrs["Url"]
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



26
27
28
# File 'lib/xero_kiwi/accounting/external_link.rb', line 26

def ==(other)
  other.is_a?(ExternalLink) && to_h == other.to_h
end

#hashObject



31
# File 'lib/xero_kiwi/accounting/external_link.rb', line 31

def hash = to_h.hash

#inspectObject



33
34
35
# File 'lib/xero_kiwi/accounting/external_link.rb', line 33

def inspect
  "#<#{self.class} type=#{link_type.inspect} url=#{url.inspect}>"
end

#to_hObject



22
23
24
# File 'lib/xero_kiwi/accounting/external_link.rb', line 22

def to_h
  ATTRIBUTES.keys.to_h { |key| [key, public_send(key)] }
end