Class: XeroKiwi::Accounting::BrandingTheme

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

Overview

Represents a Xero Branding Theme returned by the Accounting API.

See: developer.xero.com/documentation/api/accounting/brandingthemes

Constant Summary collapse

ATTRIBUTES =
{
  branding_theme_id: "BrandingThemeID",
  name:              "Name",
  logo_url:          "LogoUrl",
  type:              "Type",
  sort_order:        "SortOrder",
  created_date_utc:  "CreatedDateUTC"
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ BrandingTheme

Returns a new instance of BrandingTheme.



31
32
33
34
35
36
37
38
39
# File 'lib/xero_kiwi/accounting/branding_theme.rb', line 31

def initialize(attrs)
  attrs              = attrs.transform_keys(&:to_s)
  @branding_theme_id = attrs["BrandingThemeID"]
  @name              = attrs["Name"]
  @logo_url          = attrs["LogoUrl"]
  @type              = attrs["Type"]
  @sort_order        = attrs["SortOrder"]
  @created_date_utc  = parse_time(attrs["CreatedDateUTC"])
end

Class Method Details

.from_response(payload) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/xero_kiwi/accounting/branding_theme.rb', line 22

def self.from_response(payload)
  return [] if payload.nil?

  items = payload["BrandingThemes"]
  return [] if items.nil?

  items.map { |attrs| new(attrs) }
end

Instance Method Details

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



45
46
47
# File 'lib/xero_kiwi/accounting/branding_theme.rb', line 45

def ==(other)
  other.is_a?(BrandingTheme) && other.branding_theme_id == branding_theme_id
end

#hashObject



50
# File 'lib/xero_kiwi/accounting/branding_theme.rb', line 50

def hash = [self.class, branding_theme_id].hash

#inspectObject



52
53
54
55
# File 'lib/xero_kiwi/accounting/branding_theme.rb', line 52

def inspect
  "#<#{self.class} branding_theme_id=#{branding_theme_id.inspect} " \
    "name=#{name.inspect} type=#{type.inspect}>"
end

#to_hObject



41
42
43
# File 'lib/xero_kiwi/accounting/branding_theme.rb', line 41

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